LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-16-2015, 01:46 AM   #1
N.Rotner
LQ Newbie
 
Registered: Sep 2015
Posts: 3

Rep: Reputation: Disabled
script error (using bash command)


Hi All,
I am trying to run the following script and getting some syntacs errors. Please help me because i am stack.

The script:
----------------
#!/bin/bash

PLAYSMS=$1

if [ -z "$PLAYSMS" ]; then
echo "Usage: $0 <playSMS installation path>"
exit 1
fi

CWD=$(pwd)

##Common strings
cd $PLAYSMS/plugin
touch language/messages.pot
touch language/index.html
xgettext -L PHP --omit-header --no-location --sort-output --from-code=utf-8 -j -o language/messages.pot ../init.php
xgettext -L PHP --omit-header --no-location --sort-output --from-code=utf-8 -j -o language/messages.pot ../index.php ##Themes,plugins and tools strings
find ../lib/ -iname "*.php" -exec xgettext -L PHP --omit-header --no-location --sort-output --from-code=utf-8 -j -o language/messages.pot {} \;cd $PLAYSMS/web/plugin
find ../inc/ -iname "*.php" -exec xgettext -L PHP --omit-header --no-location --sort-output --from-code=utf-8 -j -o language/messages.pot {} \;find . -type d -name "language" | grep -v "grep" | sed -e "s/\/[^\/]*$//" > /tmp/.lang_folders
find themes/common/ -iname "*.php" -exec xgettext -L PHP --omit-header --no-location --sort-output --from-code=utf-8 -j -o language/messages.pot {} \;for i in `cat /tmp/.lang_folders` ; do mkdir -p "$i/language" ; done
for i in `cat /tmp/.lang_folders` ; do rm -f "$i/language/messages.pot" ; done
for i in `cat /tmp/.lang_folders` ; do touch "$i/language/messages.pot" ; done
for i in `cat /tmp/.lang_folders` ; do
find $i -iname '*.php' -exec xgettext -L PHP --omit-header --no-location --sort-output --from-code=utf-8 -j -o "$i/language/messages.pot" {} \; ;
touch "$i/language/index.html"
done
rm /tmp/.lang_folders
cd $CWD

exit 0

--------------------------------------------------------------------
The Error:
------------
find: missing argument to `-exec'
find: missing argument to `-exec'
1-update-pot-files.sh: line 20: syntax error near unexpected token `do'
1-update-pot-files.sh: line 20: `find themes/common/ -iname "*.php" -exec xgettext -L PHP --omit-header --no-location --sort-output --from-code=utf-8 -j -o language/messages.pot {} \;for i in `cat /tmp/.lang_folders` ; do mkdir -p "$i/language" ; done'
--------------------------------------------------------------------

Thanks,
Nimrod
 
Old 09-16-2015, 02:34 AM   #2
zhjim
Senior Member
 
Registered: Oct 2004
Distribution: Debian Squeeze x86_64
Posts: 1,748
Blog Entries: 11

Rep: Reputation: 233Reputation: 233Reputation: 233
Firs please use code tags. Makes things easier to read.

Try to escape the {} like you did with ;.
Did you run the line outside of the script and see what it does?
 
Old 09-16-2015, 03:39 AM   #3
goumba
Senior Member
 
Registered: Dec 2009
Location: New Jersey, USA
Distribution: Back to Debian, and only Debian.
Posts: 1,158
Blog Entries: 7

Rep: Reputation: 327Reputation: 327Reputation: 327Reputation: 327
As well, I recommend that you put each statement on it's own line. Some of these lines are lengthy, and you're confusing things by using semicolons to delimit statements. That code, even in code tags is needlessly difficult to read. I can see at least two such cases where it causes an error because you escape the semicolon as required by find -exec, but then fail to add a semicolon to separate it from the next statement. I can say that's the most likely reason you're getting

Code:
1-update-pot-files.sh: line 20: syntax error near unexpected token `do'
1-update-pot-files.sh: line 20: `find themes/common/ -iname "*.php" -exec xgettext -L PHP --omit-header --no-location --sort-output --from-code=utf-8 -j -o language/messages.pot {} \;for i in `cat /tmp/.lang_folders` ; do mkdir -p "$i/language" ; done'
change this line, adding the semicolon denoted in red:

Code:
find themes/common/ -iname "*.php" -exec xgettext -L PHP --omit-header --no-location --sort-output --from-code=utf-8 -j -o language/messages.pot {} \; ; for i in `cat /tmp/.lang_folders` ; do mkdir -p "$i/language" ; done
Whitespace and comments are your friends.

Get rid of the backticks. You did it right with CWD=$(pwd). Do the same everywhere. On that note, use pushd and popd, let bash do the work of storing the previous directory for you.

Last edited by goumba; 09-16-2015 at 03:43 AM. Reason: Ugh, spelling.
 
Old 09-16-2015, 05:11 AM   #4
N.Rotner
LQ Newbie
 
Registered: Sep 2015
Posts: 3

Original Poster
Rep: Reputation: Disabled
Many thanks!!! it is working!
 
Old 09-16-2015, 05:12 AM   #5
goumba
Senior Member
 
Registered: Dec 2009
Location: New Jersey, USA
Distribution: Back to Debian, and only Debian.
Posts: 1,158
Blog Entries: 7

Rep: Reputation: 327Reputation: 327Reputation: 327Reputation: 327
Quote:
Originally Posted by N.Rotner View Post
Many thanks!!! it is working!
How did you correct it? What did you do? Choose SOLVED from the Thread Tools menu so others can find it if needed.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
script error (using bash command) N.Rotner Linux - General 1 09-16-2015 02:32 AM
Bash script - command works directly in command line but not in script raoulcousins Linux - Newbie 6 08-21-2013 07:43 PM
[SOLVED] command not found error when running my bash script thras0 Programming 3 07-28-2012 02:43 PM
[SOLVED] ls command inside bash script error sopier Programming 11 12-17-2011 10:19 PM
[SOLVED] Bash Script Using "date" command error gorrillamcd Linux - Software 3 10-18-2011 07:08 PM


All times are GMT -5. The time now is 12:19 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration