I seem to be having issues with what should be a fairly simple exercise. I've tried searching all over and can't find a definitive answer.
I've got a file called ftpupload.sh that's run from a cron job. (Loaded through crontab -e as root) It uploads a series of files to an ftp server, then deletes them. (At least when run from command line). When run from the cron job, it uploads them, but doesn't delete them.
When I check the error mail, at the end of the mail is this:
/root/ftpupload.sh: 8: [: 0: unexpected operator
The script is as follows:
Code: Select all
#!/bin/sh
FTPU="Username" # ftp login name
FTPP="Password" # ftp password
FTPS="ftp.myserver.com" # remote ftp server
FTPF="/" # remote ftp server directory for $FTPU & $FTPP
LOCALD="*.jpg"
ncftpput -m -u $FTPU -p $FTPP $FTPS $FTPF $LOCALD
if [ $? == 0 ]; then
/bin/rm /root/*.jpg
fi
Code: Select all
0 */4 * * * /root/ftpupload.sh