Visit Our UNIX and Linux User Community


what's worng with this code


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting what's worng with this code
# 1  
Old 09-03-2009
what's worng with this code

Below is the simple shell script code for ftp files from Remote server -

Code:
while true
do
echo "Coping files from remote server"
sleep 1
ftp -inv $IP <<!
user $USER $PASS
cd /dcs/data01/INPUT/MSC/ERI
lcd /dcs/appl01/testing_scenario
bin
mget ERVNS*
bye
!
sleep 60
done

I am running command on Linux box and getting error -

"syntax error: unexpected end of file"

Please let me know what's wrong with this code. However when I run same command on prompt it is working.
# 2  
Old 09-03-2009
try...

Code:
while true
do
echo "Coping files from remote server"
sleep 1
ftp -inv  <<!
open $IP
user $USER $PASS
cd /dcs/data01/INPUT/MSC/ERI
lcd /dcs/appl01/testing_scenario
bin
mget ERVNS*
bye
!
sleep 60
done

# 3  
Old 09-03-2009
The error message is because the "!" is somehow not in column 1 on a line on its own. It can be caused by editing the script on a M$ platform.

Can you post the output from:

Code:
sed -n l scriptname

Based on you post, it should look like this:
The "$" represents the standard unix line terminator.

Code:
while true$
do$
echo "Coping files from remote server"$
sleep 1$
ftp -inv $IP <<!$
user $USER $PASS$
cd /dcs/data01/INPUT/MSC/ERI$
lcd /dcs/appl01/testing_scenario$
bin$
mget ERVNS*$
bye$
!$
sleep 60$
done$

# 4  
Old 09-04-2009
Hi Methyl,

Thanks for reply

Quote:
Can you post the output from:
sed -n l scriptname
Below is the output of sed -n l <my_script>

Code:
while true\r$
do\r$
echo "Coping files from remote server"\r$
sleep 1\r$
ftp -inv $IP <<!\r$
user $USER $PASS\r$
cd /dcs/data01/INPUT/MSC/ERI\r$
lcd /dcs/appl01/testing_scenario\r$
bin\r$
mget ERVNS*\r$
bye\r$
!\r$
sleep 60\r$
done\r$


it looks good to me. Please check.

Thanks.
# 5  
Old 09-04-2009
Am very sure,

that the pattern <<!
and
!

is not the same,

there is same character - a whilte space ?, that is making this incomplete file

Can you please check that?

Previous Thread | Next Thread
Test Your Knowledge in Computers #990
Difficulty: Medium
UNIX System V is one of the first commercial versions of the Unix operating system and was originally developed by AT&T and first released in 1981.
True or False?

6 More Discussions You Might Find Interesting

1. Linux

Go to a line of code , skip few lines of code

Hi , I have a code where i am using a infinite while loop . some thing like below while do if then #go to line 20 fi command 1; command 2; #line 20: sleep 34; (5 Replies)
Discussion started by: Paarth
5 Replies

2. Shell Programming and Scripting

Block of code replacement in Java source code through Unix script

Hi, I want to remove the following code from Source files (or replace the code with empty.) from all the source files in given directory. finally { if (null != hibernateSession && hibernateSession.isOpen()) { //hibernateSession.close(); } } It would be great if the script has... (2 Replies)
Discussion started by: hareeshram
2 Replies

3. UNIX for Dummies Questions & Answers

If 922 Code does not exist on 03 Record, 901 Code will be there instead, move 03 R

01,011600033,011600033,110516,0834,2,90,,2/ 02,011600033,011103093,1,110317,0834,,2/ 03,105581,,015,+00000416418,,,901,+00000000148,,,922,+000000 00354,,/ 03,113806,,015,+00000559618,,,901,+00000000096,,,922,+000000 00621,,/ 88,902,+0000000025218,,/... (1 Reply)
Discussion started by: sgoud
1 Replies

4. Shell Programming and Scripting

translate ksh code to csh code

hi all, Can any 1 help me translate this korn shell code to C shell code : email=$(grep "^$1" $folder/config_2.txt | awk '{print $2'}) In config_2.txt the content is : which mean in korn shell , $1=groupname and $2=email address. Now i need to write in C shell script,when i set the... (2 Replies)
Discussion started by: proghack
2 Replies

5. Shell Programming and Scripting

csh code to ksh code

I have this code using csh and want to convert it to ksh to include this thinking into my ksh scripts. while ( $iarg < $narg ) MATH iarg = $iarg + 1 set arg = $argv set opt=` echo $arg | awk 'BEGIN { FS="=" } { print $1 }' ` set par=` echo $arg | awk 'BEGIN { FS="=" } {... (2 Replies)
Discussion started by: kristinu
2 Replies

6. Programming

how i prepare a c++ code(c code) for implementing my own protocol format

helo my protocol format is given below { destno,mode,no.of packet,pktsize,,pktno,textsize,CRC} description:- { is starting flag destno - 4bytes mode - 1 byte no.of pkt - 4byes pktsize - 6 bytes ... (1 Reply)
Discussion started by: amitpansuria
1 Replies

Featured Tech Videos