• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Stupid shellscript problem in MacOS X Snow Leopard...

slugg

Diamond Member
Error I'm getting:

'/exeme_binarize.sh: line 1: syntax error near unexpected token `
'/exeme_binarize.sh: line 1: `for src in *.pgm;


First two lines of the shellscript:


for src in *.pgm;
do


... what?? I don't understand the problem... Thanks in advance for your help. 🙂
 
I dont know how scripting in OSX differs from Linux but you shouldn't need a semicolon at the end of the first line since its followed by a newline.

Post the rest of the script.
 
Do you literally have the `` marks around the for loop?
Do you have a #! line at the top telling it which interpreter to use?
 
Here's the whole script, as-is:

for src in *.pgm;
do
# set target file name;
tgt=`./images1procesed/$src`
echo converting $src to $tgt;
# run "binarize" function with threshold=100;
iptool binarize $src $tgt 100
done




... So no, there's no #! line, and I don't have quotes around the for loop. Removing the first semicolon, I get this error:


'/exeme_binarize.sh: line 2: syntax error near unexpected token `do
'/exeme_binarize.sh: line 2: `do



I'm utterly confused. Why wouldn't this work? Is it some quirk about OS X?
 
Looks like you still need an interpreter line: #!/bin/bash or #!/bin/sh

Also remove every semicolon. You shouldn't need those unless you are putting multiple statements on the same line.

You might also want to try using quotes instead of backticks for the statement assigning a file path to a variable.
 
Last edited:
Looks like you still need an interpreter line: #!/bin/bash or #!/bin/sh

Also remove every semicolon. You shouldn't need those unless you are putting multiple statements on the same line.

You might also want to try using quotes instead of backticks for the statement assigning a file path to a variable.

"bad interpreter: No such file or directory" for both.

Quotes versus backticks haven't made a difference yet; it doesn't get past the first line of the code. 🙁
 
"bad interpreter: No such file or directory" for both.

Quotes versus backticks haven't made a difference yet; it doesn't get past the first line of the code. 🙁

My experience with OSX is virtually non-existent but I figured I'd give it a try. You may want to find a Mac forum at this point.
 
"bad interpreter: No such file or directory" for both.

Quotes versus backticks haven't made a difference yet; it doesn't get past the first line of the code. 🙁

If OS X doesn't store bash at /bin/bash, then where is it?
 
If OS X doesn't store bash at /bin/bash, then where is it?
In other words, use '#' followed the the result of `which bash`.

Edit: You can use the result of this command for the first line:
echo "#`which bash || which sh`"
 
Back
Top