Syntax error near unexpected token


 
Thread Tools Search this Thread
# 1  
Syntax error near unexpected token

hi! just want to seek help on this error: syntax error near unexpected token 'do

this is my script

Code:
# !/bin/sh
#


for y in 27 25
do
exemmlmx -c "ZEEI;" -n XRT$y >> blah
done

what can be wrong? thanks!

Last edited by Scott; 09-26-2010 at 12:58 PM.. Reason: Please use code tags
# 2  
Hi.

The script looks fine.

If I had to guess, you have a control character (possibly a ^M) after the do.

Which OS are you using? Di you copy the script from Windows?

Last edited by Scott; 12-03-2010 at 10:40 PM..
# 3  
hi! thanks for the reply.

but what do you mean by control character?

i didn't use vi editor. i just ftp-ed it
# 4  
Quote:
Originally Posted by engr.jay
hi! thanks for the reply.

but what do you mean by control character?

i didn't use vi editor. i just ftp-ed it
Hi.

You ftp'd it from where?
# 5  
Quote:
Originally Posted by scottn
Hi.

You ftp'd it from where?

from my pc.
# 6  
You need to make sure you are using ascii mode, not binary mode... when you transfer a text file from your PC using ftp.
# 7  
Quote:
Originally Posted by scottn
Hi.

The script looks fine (except for the space on the first line between # and !)

If I had to guess, you have a control character (possibly a ^M) after the do.

Which OS are you using? Di you copy the script from Windows?
Correct me if I'm wrong, but doesn't the shebang not work with the space after the pound-sign? It seems to me that the script isn't running in bash but whatever the OP's default shell is.

I'd try removing the space between # and ! before anything else.
 

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Syntax error near unexpected token 'do'

Hello all, Please i have this command i used to zip different files in differents directory, but i have an error. Note that when i run the command in one directory it works fine. /X5/WORK/BGH/INV/REG/pdf/SEND/BGH12523/1/*.fo /X5/WORK/BGH/INV/REG/pdf/SEND/BGH24523/1/*.fo... (3 Replies)
Discussion started by: gillesi
3 Replies

2. How to Post in the The UNIX and Linux Forums

Syntax error near unexpected token `('

I have 2 files like a.txt and b.txt and the content is as below cat a.txt 810750125 117780 /BSCSQAT4A/bscsqat4a/lib/jar/wclt_common.jar 1803152428 13300 /BSCSQAT4A/bscsqat4a/lib/jar/WFMSSupportTool.jar 2663502779 67049 /BSCSQAT4A/bscsqat4a/lib/jar/wma.jar 687942896 665272... (1 Reply)
Discussion started by: ranabhavish
1 Replies

3. Shell Programming and Scripting

Syntax error near unexpected token

Hi all, I have a simple script that doesn't work somehow. I can't seem to be spotting the cause of the malfunction. count=$((1)) for item in `cat test1.txt` printf %s `sed -n $((count))p test2.txt` > test3.txt count=$((count+1)) do something done I get ; ./why.sh: line 3:... (14 Replies)
Discussion started by: y33t
14 Replies

4. Shell Programming and Scripting

Syntax error near unexpected token `else'

Hi, I am trying to read the session log through script. But it keeps showing me some error near. I have tried everything. Even tried converting the script using sed command to remove the hidden characters(\r).But nothing seems to be working.Below is the script : #!/bin/bash cd... (6 Replies)
Discussion started by: Aryan12345
6 Replies

5. Homework & Coursework Questions

Syntax error near unexpected token 'else'

1. The problem statement, all variables and given/known data: line 37: syntax error near unexpected token 'else' line 37: ' else' the script is made to take 1 or 2 command line arguments however i get the above stated error when trying to process it. This happens with or without arguments... (6 Replies)
Discussion started by: Ren_kun
6 Replies

6. Shell Programming and Scripting

Syntax error near unexpected token `}' please help

I'm going mad not being able to get this to work. im assuming its only a simple mistake but its driving me bonkers trying to find it. Please if you can help me it would save me pulling my hair out!! Thanks #!/bin/bash -xv # #Config name="TEST Server" + name='TEST Server'... (6 Replies)
Discussion started by: Fisheh
6 Replies

7. Shell Programming and Scripting

syntax error near unexpected token `='

Hi all, This is a script which converts hex to bin. However am finding an error while executing syntax error near unexpected token `=' `($hexfile, $binfile) = @ARGV;' I am running using ./fil.pl <hexfile> <binfile> ################################################### # # this script... (3 Replies)
Discussion started by: jaango123
3 Replies

8. UNIX for Advanced & Expert Users

syntax error near unexpected token '{

Hi, I am running the following script through cygwin and getting below mentioned error. ******************************************* #!/bin/sh # constants WORK_DIR="deploy" INFOFILE="deploy.info" INTROFILE="Intro.sh" CMGMT_PKG="com.kintana.cmgmt.deploy" DEPLOY_PREFIX="mitg" ... (2 Replies)
Discussion started by: MandyR
2 Replies

9. Shell Programming and Scripting

Syntax error near unexpected token `done'

Hi all, Here is a simple script that is working in one server and is giving a syntax error in other server. Can somebody help me ? #!/bin/bash # ftp files done < $file errors: I tried..with no success: if ; then (21 Replies)
Discussion started by: Lenora2009
21 Replies

10. Shell Programming and Scripting

sh syntax error unexpected token done

I'm getting the following error: line 21: syntax error near unexpected token `done` line 21: `done` and I haven't been able to figure out why. Here is my code #!/bin/sh if ; then echo 'Usage: rename getexp/replStr ' exit 0 fi arg = $1 shift while ; do (5 Replies)
Discussion started by: NullPointer
5 Replies

Featured Tech Videos