Shell Script problem
Hi Everyone,
I got a little shell problem. When I execute the following shell script: for((i=0; i<=2; i++)) do /usr/bin/wget -t 1 -O/dev/null -q http://ur; echo "passed"; sleep 5; done I'm getting this error: 'ownloadCron.sh: line 1: syntax error near unexpected token ` 'ownloadCron.sh: line 1: `for((i=0; i<=2; i++)) But I can't find any unexpected token exactly. What can be the problem? Thanks Arian |
then you must have typed a “`” character, which shouldn't be there.
Yves. |
Fixed
I checked but I couldn't find any. So I typed everything again, but now not in an editor of windows but in the vi editor on the commandline. It worked. Could it have to do something with how the files are stored in windows?
|
Quote:
|
The main concern is the sequence of characters used by windows to terminate a line. DOS and Windows adopted the CR+LF style, that is a carriage return followed by a line feed. In Unix notation it is the sequence \r\n.
Unix systems adopted a simple LF, that is \n. Commonly you call this a newline character. For text files created in Windows you can use the utility dos2unix to convert them in Unix format. See man dos2unix for details. The presence of a carriage return triggers some common errors in BASH and other shell scripting languages. To discover the presence of \r\n in Unix or Linux you can try the od command. Suppose you have a file containing the line "Hello world!". If it has been created in Linux you will see: Code:
$ od -c file Code:
$ od -c file |
All times are GMT -5. The time now is 07:14 AM. |