akelabanda
Programmer
Hi Folks
Wondering if you can help me with my script. I'm trying to run an unattended FTP session from within a shell script. The FTP uses servername, username and password from a text file. I'm getting an error:
syntax error at line 34: `end of file' unexpected
The file has only 33 lines.
I previously ran a successful script -
----------------------------------
for SW in srvr1 srvr2
do
FILE=/var/tmp/$$.${SW}.lst
NEWFILE=/var/tmp/$$.${SW}.new
ftp -n ${SW} <<-EOF > ${FILE}
user ${USR} ${PSW}
dir
EOF
----------------------------------
However, I'm now trying to do it this way -
----------------------------------
while read dta
do
SWID=`echo "$dta" | awk -F"|" '{print $1}'`
SWHOST=`echo "$dta" | awk -F"|" '{print $2}'`
SWUSR=`echo "$dta" | awk -F"|" '{print $3}'`
SWPASSWD=`echo "$dta" | awk -F"|" '{print $4}'`
SWPATH=`echo "$dta" | awk -F"|" '{print $5}'`
echo "$SWID $SWNAME $SWUSR $SWPASSWD $SWPATH"
FILE=/var/tmp/$$.$SWHOST.lst
NEWFILE=/var/tmp/$$.$SWHOST.new
ftp -n <<EOT
OPEN $FILE
user $SWUSR $SWPASSWD
dir
EOT
done < flat_file
----------------------------------
This is throwing up the error mentioned above. If I comment out the FTP part of the code, the script doesn't complain.
Any ideas why this could be happenning ?
The ascii file is in the form:
ID|REMOTEHOST|UNAME|PASSWD|PATH
Thanks for your help.
Regards
Raj
UK's best mobile deals online
Wondering if you can help me with my script. I'm trying to run an unattended FTP session from within a shell script. The FTP uses servername, username and password from a text file. I'm getting an error:
syntax error at line 34: `end of file' unexpected
The file has only 33 lines.
I previously ran a successful script -
----------------------------------
for SW in srvr1 srvr2
do
FILE=/var/tmp/$$.${SW}.lst
NEWFILE=/var/tmp/$$.${SW}.new
ftp -n ${SW} <<-EOF > ${FILE}
user ${USR} ${PSW}
dir
EOF
----------------------------------
However, I'm now trying to do it this way -
----------------------------------
while read dta
do
SWID=`echo "$dta" | awk -F"|" '{print $1}'`
SWHOST=`echo "$dta" | awk -F"|" '{print $2}'`
SWUSR=`echo "$dta" | awk -F"|" '{print $3}'`
SWPASSWD=`echo "$dta" | awk -F"|" '{print $4}'`
SWPATH=`echo "$dta" | awk -F"|" '{print $5}'`
echo "$SWID $SWNAME $SWUSR $SWPASSWD $SWPATH"
FILE=/var/tmp/$$.$SWHOST.lst
NEWFILE=/var/tmp/$$.$SWHOST.new
ftp -n <<EOT
OPEN $FILE
user $SWUSR $SWPASSWD
dir
EOT
done < flat_file
----------------------------------
This is throwing up the error mentioned above. If I comment out the FTP part of the code, the script doesn't complain.
Any ideas why this could be happenning ?
The ascii file is in the form:
ID|REMOTEHOST|UNAME|PASSWD|PATH
Thanks for your help.
Regards
Raj
UK's best mobile deals online