homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Visit PubCon.com
Home / Forums Index / Hardware and OS Related Technologies / Linux, Unix, and *nix like Operating Systems
Forum Library, Charter, Moderators: bakedjake

Linux, Unix, and *nix like Operating Systems Forum

Help with bash script
syntax seems correct

 2:58 pm on Jan 5, 2007 (gmt 0)

Using SuSe 10.1, I have a shell script that checks a PSV file and if the file has content (greater than zero) loads an sql text command into MySQL. The syntax seems correct, but I get an error that a there is an unrecognized "token" before "fi".

The file is named pipefilechk.sh and it is in the /bin/ folder. I try to call it in command line with "exec pipefilechk.sh".

I also have it in a crontab, but it is not working.


if [-s /usr/local/src/blist.psv];

/usr/bin/mysql -u someuser -p somepassword < /usr/local/src/blist.sql;

When I just type the "then" command directly into command line, it works.



 3:41 pm on Jan 5, 2007 (gmt 0)

2 things to try:
- remove both trailing ';'
- the ' [ ' and ' ] ' should each have a space before and after so it should read
if [ -s /usr/local/src/blist.psv ]
The ' [ ' is not just a bracket, it is the test command.

Kind regards,


 6:23 pm on Jan 5, 2007 (gmt 0)

Thanks. I had tried removing the ; and I noticed the [ spaces ] after posting here.

The more I read, though, the more I realize that this whole issue is specific to bash syntax and shell commands. It is a mess, because my script is using reserved shell commands (-u and -p in the mysql command, and the dot in the files).

This is why it was seing "tokens".

I can't find a work around in the manual or reference files. And only someone who knows shell can answer this.

I suspect it can only be done with assigning variables. But the actual syntax is still escaping me (no pun).

Global Options:
 top home search open messages active posts  

Home / Forums Index / Hardware and OS Related Technologies / Linux, Unix, and *nix like Operating Systems
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved