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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ftp inside "if" fails

Status
Not open for further replies.

rattrap47

Programmer
Dec 15, 2008
6
US
I have the following script where I'm trying to ftp a file after a test:

------------ Begin Script ----------------------------
[tt]
#!/bin/bash -x
HOST="64.102.94.191"
FTPUSER="anonymous"
FTPPASSWORD="CNC-Bot"
tgfile="/home/rlevau/collections/transport-usa1.zip"

dltype=`grep -i 'downloadingtype' /home/rlevau/download/out/download.hdr | tr -d '<DownloadingType>/'`

if [ "$dltype" = "Fu" ]; then
ftp -inv $HOST <<-EOF
user $FTPUSER $FTPPASSWORD
put $tgfile
bye
fi
[/tt]
--------------------- End Script --------------------

I get an "unexpected end of file" error. Can someone please tell me where I'm going astray?

TIA
 
...
bye
[!]EOF[/!]
fi

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Unfortunately I got the same error.

Does the fact that it's Solaris 10 make any difference?
 
Can you show exact script please?

The EOF keyword should be on a line by itself, without any spaces in front of it. A TAB is ok, because you specified <<-EOF for your "here document".

Also check out if maybe you have CRLF as end of line chars, should be just LF. Happens if you edit the file under windoze, then try to run it as is on UNIX/Linux...

see if you have a dos2unix program to convert CRLF to LF.



HTH,

p5wizard
 
okay, I removed the if and it STILL fails, I'm confused...

facts to remember:
1. the script was built, edited, and is going to run on a Solaris 10 machine
2. the target ftp box is win2003 server (32 bit)
3. anonymous login works from shell prompt

[tt]
#!/bin/bash -x

HOST="64.102.94.191"
FTPUSER="anonymous"
FTPPASSWORD="CNC-Bot"
tgfile="/home/rlevau/collections/transport-usa1.zip"

#dltype="Fu"
#echo $dltype
ls $tgfile

#if [ "$dltype" = "Fu" ]; then
ftp -inf $HOST
user $FTPUSER $FTPPASSWORD
put $tgfile
quit
#fi
[/tt]
 
Why have you also removed the EOFs? You have also changed bye to quit?

I want to be good, is that not enough?
 
Hi

Code:
#!/bin/bash -x
HOST="64.102.94.191"
FTPUSER="anonymous"
FTPPASSWORD="CNC-Bot"
tgfile="/home/rlevau/collections/transport-usa1.zip"

dltype=`grep -i 'downloadingtype' /home/rlevau/download/out/download.hdr | tr -d '<DownloadingType>/'`

if [ "$dltype" = "Fu" ]; then
 ftp -inv $HOST <<-EOF
 user $FTPUSER $FTPPASSWORD
 put $tgfile
 bye
[COLOR=pink red]EOF[/color]
[red]# ^- PHV's suggestion - you really need it ![/red]
fi

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top