Operating System - HP-UX
1838271 Members
3712 Online
110125 Solutions
New Discussion

Re: error ftp shell script automatic

 
Jairo Campana
Trusted Contributor

error ftp shell script automatic

Hi , I have a error in shell script when use condition if and EOF
syntax error: unexpected end of file

if [ -s test ]
then
ftp -n -i $SRV <<-EOF
quote USER $ADM
quote PASS $PWD
bin
mput test
quit
EOF
else
exit
fi

legionx
8 REPLIES 8
James R. Ferguson
Acclaimed Contributor

Re: error ftp shell script automatic

Hi Jairo:

If you have a blanks character and not a tab character before your EOF you will receive a syntax error: "`<<' is not matched".

ALSO, using a file named 'test' is not a good practice.

Regards!

...JRF...
Jairo Campana
Trusted Contributor

Re: error ftp shell script automatic

<< eof obtaing the mismatch error syntax error: unexpected end of file
legionx
Jairo Campana
Trusted Contributor

Re: error ftp shell script automatic

I change script but error persist:

if [ -s $CARP/FC ]
then
ftp -n -i $SRV< quote USER $ADM
quote PASS $PWD
bin
lcd $CARP
mput FC
quit
EOF
else
exit
fi
legionx
Laurent Menase
Honored Contributor

Re: error ftp shell script automatic

PWD is reserved in shell.
use PWRD
Jairo Campana
Trusted Contributor

Re: error ftp shell script automatic

ok , change variable for PWDR, but the problem and error persist:

ine 4 syntax error: unexpected end of file
legionx
OldSchool
Honored Contributor

Re: error ftp shell script automatic

ok, the following works....

be very careful of spaces / tabs

if [ -s fsm.data ]
then
ftp -v -n -i $SVR < quote USER ${ADM}
quote PASS ${PASSW}
ls
quit
EOF
else
echo in else
fi
Laurent Menase
Honored Contributor

Re: error ftp shell script automatic

One thing, to debug that sort of problem you can use "set -x"
then you will have an exact trace of what is executed.
OldSchool
Honored Contributor

Re: error ftp shell script automatic

check the man page for the shell you are using regarding here-doc

<< doesn't strip characters, so the EOF indicator *MUST* begin in the first column

<<- strips but not spaces, so the EOF indicator can follow a or but not spaces...i.e you can't have EOF and make it work