Operating System - HP-UX
1833780 Members
2983 Online
110063 Solutions
New Discussion

<< UNMATCHED error with << FTPEOF VERY URGENT!!

 
SOLVED
Go to solution
Sander Derix
Occasional Advisor

<< UNMATCHED error with << FTPEOF VERY URGENT!!

Hi group,

I keep getting this error:
2) Check connection FTP server
xx.xxx.xx.xx is alive
./ftp.sh[51]: syntax error at line 55 : `<<' unmatched
What the f#ck is wrong with this?
I copied this from another script wich runs every night, so this should work fine. Why do I get the error?!?!!?!?!? Is it because of the gremlins in my computer?

ftp -nv $2 << FTPEOF # > /tmp/temp_log.$$
user $3 $4
cd $5 #Switch to directory
get $1 #Get file

Sander
17 REPLIES 17
john korterman
Honored Contributor
Solution

Re: << UNMATCHED error with << FTPEOF VERY URGENT!!

Hi Sander,
you need the string
FTPEOF
in your script to mark the end of the "here-script". It must not be indented.

Hope it helps
John K.
it would be nice if you always got a second chance
steven Burgess_2
Honored Contributor

Re: << UNMATCHED error with << FTPEOF VERY URGENT!!

Sander

You need to at the end

bye
EOF

No need for the language mate

Steve
take your time and think things through
steven Burgess_2
Honored Contributor

Re: << UNMATCHED error with << FTPEOF VERY URGENT!!

ie

ftp -inv << EOF
open
user
binary
cd /home/
get .profile
bye
EOF


Steve
take your time and think things through
Robin Wakefield
Honored Contributor

Re: << UNMATCHED error with << FTPEOF VERY URGENT!!

And make sure the final FTPEOF starts at column position 1, no leading spaces allowed.

Rgds, Robin
Sander Derix
Occasional Advisor

Re: << UNMATCHED error with << FTPEOF VERY URGENT!!

Hi guys,

thnx for the reply.

Sorry to say but i've got an EOF!


ftp -nv $2 << FTPEOF # > /tmp/temp_log.$$
user $3 $4
cd $5 #Switch to directory
get $1 #Get file
FTPEOF #End spool

So what else can be the problem?

Sander

steven Burgess_2
Honored Contributor

Re: << UNMATCHED error with << FTPEOF VERY URGENT!!

What about the

bye

Steve
take your time and think things through
Sander Derix
Occasional Advisor

Re: << UNMATCHED error with << FTPEOF VERY URGENT!!

Extra info
I've taken out 1 < before FTPEOF (line no 50 approx.)
In the result you see a line
3) Conection succesfull
I didn't get that when I had <

Here's the entire script:
#-------------
# CONSTANTS
#------------
FILE=$1
SERVER=$2
USERNAME=$3
PASSWORD=$4
FTP_DIR=$5
EMAILADRES=$6 #"sander.derix@office.xerox.com"

#-------------
# LOG
#-------------
LOG=/tmp/$1.log
MSG=/tmp/$1.msg
echo "File transfer $1 to QAD failed" > $MSG

#----------------------------------------------------
echo "1) Checking for an Existing Input File"
cd /tmp
echo "1) Checking for an Existing Input File"
cd /tmp
cp $FILE $FILE-01

echo "2) Check connection FTP server"
#----------------------------------------------------
/usr/sbin/ping ${SERVER} >$LOG
grep -i "alive" $LOG
i=$?
if [ "$i" = "0" ] ; then

echo "3) Conection succesfull"
ftp -inv $SERVER < FTPEOF
user $3 $4
cd $5 #Switch to directory
get $1 #Get file
>> FTPEOF #End spool

if test $? = 0 ; then
cat /tmp/temp_log.$$ >>$MSG
echo ====
echo "FTP of $1 completed successfully."
echo ====
"ftp.sh" 85 lines, 3254 characters
(opbdev1:cpiddvl) /u/appl/sderix/test-> ./ftp.sh .dat xx.xxx.xx.xx ftp>
./ftp.sh: !/bin/ksh: not found
1) Checking for an Existing Input File
2) Check connection FTP server
xx.xxx.xx.xx is alive
3) Conection succesfull
./ftp.sh[54]: FTPEOF: cannot open
./ftp.sh[55]: user: cannot execute
./ftp.sh[56]: /dg03/ftp_get: not found
ERROR [.dat]: not an SCCS file (co1)
cat: cannot open /tmp/temp_log.5928
====
FTP of mf680sfr.dat completed successfully.
====
./ftp.sh[65]: /tmp/mf680sfr.dat.msg: cannot execute
mailnote sent to
The flags you gave are used only when sending mail.
Usage: mailx -eiIUdFntBNHvV~ -T FILE -u USER -h hops -r address
-s SUBJECT -f FILE users
john korterman
Honored Contributor

Re: << UNMATCHED error with << FTPEOF VERY URGENT!!

Hi again,

I do not think that it is allowed to have anything but that EOF string on the line - not even a comment.

regards,
John K.
it would be nice if you always got a second chance
Robin Wakefield
Honored Contributor

Re: << UNMATCHED error with << FTPEOF VERY URGENT!!

Hi Sander,

You shouldn't have taken out the "<", that's why you're getting the new errors.

Take out the ">> " before the FTPEOF, and make sure the FTPEOF line is on it's own, starting at column 1.

Rgds, Robin.
john korterman
Honored Contributor

Re: << UNMATCHED error with << FTPEOF VERY URGENT!!

Hi again again,
I'm afraid it does not make sense taking one > out, as the script now believes that FTPEOF is an input file. Try and insert it again and make sure
FTPEOF
appears alone on a line.

regards,
John K.
it would be nice if you always got a second chance
Sander Derix
Occasional Advisor

Re: << UNMATCHED error with << FTPEOF VERY URGENT!!

Hi there,

When I use the line
ftp -inv $SERVER < FTPEOF I get an error about unmatched <<

When I use this:(it's what i've got now):
ftp -inv $SERVER < FTPEOF
$USERNAME $PASSWORD
cd FTP_DIR get $FILE
EOF

I get this error:
220 vensun29 FTP server (SunOS 5.6) ready.
221 Goodbye.
./ftp.sh[55]: : not found
./ftp.sh[56]: /dg03/ftp_get: not found

Regards,

Sander

James R. Ferguson
Acclaimed Contributor

Re: << UNMATCHED error with << FTPEOF VERY URGENT!!

Hi:

'here" documents must follow this structure:

cat << EOF #...comments OK; EOF will end; note "<<"
echo hello
date
echo bye
EOF
# Note the EOF must start in leftmost column!
# Note that nothing else is allowed on that line!

Regards!

...JRF...
Robin Wakefield
Honored Contributor

Re: << UNMATCHED error with << FTPEOF VERY URGENT!!

Hi Sander,

I suspect you now have a file called FTPEOF in the directory where you are running the script, created from one of your tests. I would remove it before you do anything else.

Just try it with this:

ftp -nv $2 << FTPEOF # > /tmp/temp_log.$$
user $3 $4
cd $5
get $1
FTPEOF

don't put any trailing comments on any lines either.

Rgds, Robin
Sander Derix
Occasional Advisor

Re: << UNMATCHED error with << FTPEOF VERY URGENT!!

Okay,

i've taken you're advise into account. This is what I've got:

ftp -inv $SERVER
<$USERNAME $PASSWORD
cd $FTP_DIR
get $FILE
FTPEOF

No lines have anything before it or behind it.

I still get the same error:
./ftp.sh[51]: syntax error at line 55 : `<<' unmatched

Except that the line no changed :-(

Sander
Jean-Luc Oudart
Honored Contributor

Re: << UNMATCHED error with << FTPEOF VERY URGENT!!

try
ftp -inv $SERVER <$USERNAME $PASSWORD
cd $FTP_DIR
get $FILE
FTPEOF

you have to move 2nd line up to end of 1st line.

Jean-Luc
fiat lux
john korterman
Honored Contributor

Re: << UNMATCHED error with << FTPEOF VERY URGENT!!

Hi again,
As I suggested earlier you should go back to your original version of your script:

......<< FTPEOF
.....
.....
FTPEOF

and correct the shell of your script:
!/bin/ksh: not found
indicates a spelling error, correct it to
#!/bin/sh
that might help

You stated that you copied the script. If you did a cut an paste there is a chance that you have copied some garbage too. If you - when using the original version of your script - still get the unmatched error, then try and delete the line containing
FTPEOF
and type it in again, manually.

regards,
John K
it would be nice if you always got a second chance
Sander Derix
Occasional Advisor

Re: << UNMATCHED error with << FTPEOF VERY URGENT!!

John AND EVERYBODY ELSE OF COURSE!!
I changed the !/bin/ksh to #!/bin/ksh
I put the << FTPEOF back
nothing: the same error

I deleted the FTPEOF and:
SUCCESS! IT WORKS!!!!!!

Thank you so very much!! I really need to get some books. I had to sent in the file at 15:45 (Dutch time) so I still have 7 minutes... :-)

Regards,

Sander