shell script stopped working --- need to rewrite?
- by OopsForgotMyOtherUserName
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