1826325 Members
3554 Online
109692 Solutions
New Discussion

run script error

 
SOLVED
Go to solution
peterchu
Super Advisor

run script error

I have a very simple script but can't run ,

for x in $(ls -1 *.csv)
do
y=$(echo $x|awk -F. '{print $1}')
quoter -d "," $x>$y.q
done

it pop the below error ,

'/script1: line 2: syntax error near unexpected token `do
'/script1: line 2: `do

could suggest what is wrong in my system ? thx
6 REPLIES 6
Anupam Anshu_1
Valued Contributor

Re: run script error

I tried the given script but didn't find error at line no. 2. Please try the script as below:

----------------------------------
for x in `ls -1 *.csv`
do
y=$(echo $x|awk -F. '{print $1}')
quoter -d "," $x>$y.q
done
-----------------------------------

BTW, which shell are you using (i.e. ksh, sh ..etc). You can try changing the shell and then executing the script too.

Regards,

Anshu

Re: run script error

hi

maybe you wrote it in windows system and when you put it ftp you use bin non ascii transport
Mark Grant
Honored Contributor
Solution

Re: run script error

Well, I can't quite see why it wouldn't work but you have far more in there than you need.

Try

for x in *.csv
do

instead of what you have there.
Never preceed any demonstration with anything more predictive than "watch this"
KapilRaj
Honored Contributor

Re: run script error

ls -1 |while read line
do
y=`echo $x|awk -F. '{print $1}'`
....
...
done


Kaps
Nothing is impossible
Andres Stickar
Frequent Advisor

Re: run script error

Which shell are you using to run the script ?
try

#!/bin/sh

in the first line

Regards
Tapas Jha
Valued Contributor

Re: run script error

Hi,
Yours are perfect one. Check whether any control chars are there or not? Or have you written in dos and ftp'd it.
If so then run dos2ux (shellscriptname) > (newname)

Rgds
Tapas
Tapas Jha