Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Automate ftp 1

Status
Not open for further replies.

akelabanda

Programmer
Dec 19, 2001
61
IN
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
 
ftp -n <<[!]-[/!]EOT
[!]Tabchar[/!]OPEN $FILE
[!]Tabchar[/!]user $SWUSR $SWPASSWD
[!]Tabchar[/!]dir
EOT

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
In your shell man page have a look at the << redirection.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top