osx bash script help?
trying to make bash script in osx that continually looks at a
directory and runs an app called dcraw when there are at least 2 .nef files in that directory. getting a syntax error on the line that starts with y0. the way i've been trying to write it is to have the script watch the directory for input; that's the count function. once there's at least 2 files it jumps to the processing function where it puts the name of the first file into a variable (A) and gives variable A to the dcraw app as the file to process. the idea being that files are always processed in order this way. if the number of files drops below 2 the script would return to counting until there are once again 2 or more .nef files. probably lots of inelegant parts to this but it's the y0 line that's got me hung up right now. thanks in advance for any help. the script follows: Code:
#!/bin/bash |
Do you see that "; do" you have at the end of the "while" line?
You need another one just like it at the end of the "for" line (the next one in the script). Don't forget the semicolon. Hope this helps. |
thanks wjevans. will look at that when i get back on the
box in the morning. didn't get the error on that line, though. when the error came up it displayed the next line. would omitting the "; do" on the previous line cause bash to display the error for the next line? is that how bash does things? thanks again, BabaG |
Yep, that's how bash does things.
The reason it bombs on the next line is that even though the recommended fix is on the line I said it's on, there is technically no error on that line. It's just that bash expects certain things _after_ what's on that line, and by the time it reads the next line, it hasn't found them. If that makes any sense. Incidentally, part of where you put the fix is a matter of style. Here's the style you use: Code:
for A in blah blah; do Code:
for A in blah blah Incidentally, you get the same two choices of style in the previous "while" line. Between the two style examples above in the reply you're reading now, I chose the first one when I wrote my original answer, because that made the style of your "for" statement the same as the style in your "while" statement. (I use the other style myself, because that makes the "do" line up with the "done", and for me that makes things more readable. This is a religious issue.) Hope this helps. |
thanks wjevans! with your help i was able to get it to run.
|
All times are GMT -5. The time now is 10:03 PM. |