shell script stopped working --- need to rewrite?

Posted by OopsForgotMyOtherUserName on Stack Overflow See other posts from Stack Overflow or by OopsForgotMyOtherUserName
Published on 2010-03-27T16:39:22Z Indexed on 2010/03/27 16:43 UTC
Read the original article Hit count: 178

Filed under:
|
|

The script below worked on my Mac OS X. I'm now using Ubuntu OS, and the script is no longer working. I'm wondering if there's something that I need to change here? I did change the first line from #!/bin/bash to #!/bin/sh, but it's still throwing up an error.... Essentially, I get an error when I try to run it:

Syntax error: end of file unexpected (expecting ")")

#!/bin/sh
REMOTE='ftp.example.com'
USER='USERNAME'
PASSWORD='PASSWORD'
CMDFILE='/jtmp/rc.ftp'
FTPLOG='/jtmp/ftplog'
PATTERN='SampFile*'

date > $FTPLOG
rm $CMDFILE 2>/dev/null

LISTING=$(ftp -in $REMOTE <<EOF
user $USER $PASSWORD
cd download
ls $PATTERN
quit
EOF )

echo "open $REMOTE" >> $CMDFILE
echo "user $USER $PASSWORD" >> $CMDFILE
echo "verbose" >> $CMDFILE
echo "bin" >> $CMDFILE
echo "cd download" >> $CMDFILE
 for FILE in $LISTING
  do
   echo "get $FILE" >> $CMDFILE
  done
echo "quit" >> $CMDFILE

  ftp -in < $CMDFILE >> $FTPLOG 2>&1

rm $CMDFILE

© Stack Overflow or respective owner

Related posts about ubuntu

Related posts about shell