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]; then
/usr/bin/mysql -u someuser -p somepassword < /usr/local/src/blist.sql; fi ********************
When I just type the "then" command directly into command line, it works.
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.
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).