LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 09-16-2008, 05:43 AM   #1
Abstractt
LQ Newbie
 
Registered: Nov 2007
Posts: 11

Rep: Reputation: 0
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
 
Old 09-16-2008, 06:00 AM   #2
theYinYeti
Senior Member
 
Registered: Jul 2004
Location: France
Distribution: Arch Linux
Posts: 1,897

Rep: Reputation: 66
then you must have typed a “`” character, which shouldn't be there.

Yves.
 
Old 09-16-2008, 06:14 AM   #3
Abstractt
LQ Newbie
 
Registered: Nov 2007
Posts: 11

Original Poster
Rep: Reputation: 0
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?
 
Old 09-16-2008, 07:46 AM   #4
snkmchnb
LQ Newbie
 
Registered: Sep 2008
Posts: 4

Rep: Reputation: 1
Quote:
Originally Posted by Abstractt View Post
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?
I had this issue yesterday, actually. Its the actual format the file is stored in.. at least that was my issue. Something you can do is use and editor like Notepad++ (if you have to write it in Windows) which allows UNIX file formats.
 
Old 09-16-2008, 04:00 PM   #5
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
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
0000000   H   e   l   l   o       w   o   r   l   d   !  \n
0000015
whereas if it has been created in Windows you will see:
Code:
$ od -c file
0000000   H   e   l   l   o       w   o   r   l   d   !  \r  \n
0000016
See also http://en.wikipedia.org/wiki/Newline for details about the "newline problem".

Last edited by colucix; 09-16-2008 at 04:02 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell script problem Ashkan_s Linux - Software 3 07-27-2008 07:37 AM
shell script problem bondoq Linux - Newbie 4 07-02-2006 06:31 AM
shell script problem, want to use shell script auto update IP~! singying304 Programming 4 11-29-2005 05:32 PM
Shell script problem maringat Linux - Software 5 07-25-2005 05:12 PM
shell script problem steltner Programming 0 05-17-2003 03:26 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 03:18 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration