ftp while do error

2019-09-20 01:11发布

问题:

Anyone can help what will be the problem?

   Host='192.153.222.1'
   User='ftpuser'
   passwd='apple'
   logfile='a.log'

   while :; do
   ftp -n -p -v $HOST < example.script >> $logfile
   grep -qF "Connected" $logfile &&
   grep -qF "File successfully transferred" $logfile && break
   done

   quote USER $USER
   quote PASS $PASSWD

example.script contains

    put example.txt

The error is

./example.sh: line 20: syntax error: unexpected end of file

回答1:

Some fixes:

  • You missed the closing quote in:

    Host='192.153.222.1'

  • Use a single <, otherwise it's an "here document" in:

    ftp -n -p -v "$HOST" < example.script >> "$logfile"



回答2:

Why you use << in this line?

ftp -n -p -v $HOST << example.script >> $logfile

Change it to

ftp -n -p -v $HOST < example.script >> $logfile

It will work :-)



标签: bash shell unix