How about this code?
Code:
#!/bin/sh
# Configure variables at the begining of the script
MONITOR_DIR=/var/www/web12/web/php-site-monitor/files
TMP_DIR=/var/www/web12/web/php-site-monitor/files/tmp
SUCCESS_DIR=/var/www/web12/web/php-site-monitor/files/success
FAILED_DIR=/var/www/web12/web/php-site-monitor/files/failed
FILE_EXT=flv
# FTP variables
FTP_HOST=upload-ftp.simplecdn.com
FTP_USER=myuser
FTP_PASS=mypass
FTP_REMOTE_DIR=/
cd $MONITOR_DIR
COUNT_FILES=$(ls -l *.$FILE_EXT | grep ^- | wc -l)
if [ $COUNT_FILES -gt 0 ]; then
echo "A total of" $COUNT_FILES "file(s) found.";
echo "Creating TEMP directory:" $TMP_DIR/$PROCCESS_ID_DIR;
mkdir $TMP_DIR/$PROCCESS_ID_DIR
for f in *.$FILE_EXT; do
echo "Moving file:" $f "to:" $TMP_DIR/$PROCCESS_ID_DIR;
mv $f $TMP_DIR/$PROCCESS_ID_DIR
done
cd $TMP_DIR/$PROCCESS_ID_DIR
for f in *.$FILE_EXT; do
echo "Uploading file via FTP:" $f
ftp -in $FTP_HOST <<EOF
user $FTP_USER $FTP_PASS
binary
cd $FTP_REMOTE_DIR
put $f
bye
EOF
if [ $? -eq 0 ]
then
echo "FTP File Upload Completed:" $f
mv -f $f $SUCCESS_DIR
else
echo "FTP File Upload Failed:" $f
mv -f $f $FAILED_DIRs
fi
done
echo "Uploads completed...";
echo "Deleting TEMP folder:" $TMP_DIR/$PROCCESS_ID_DIR;
rm -rf $TMP_DIR/$PROCCESS_ID_DIR
else
echo "No files found... Exit!";
fi
Running that will output something like this:
Code:
[root@linux1]# ./shell_php.sh
A total of 3 file(s) found.
Creating TEMP directory: /var/www/web12/web/php-site-monitor/files/tmp/2010-07-23_22-25-15
Moving file: test1.flv to: /var/www/web12/web/php-site-monitor/files/tmp/2010-07-23_22-25-15
Moving file: test2.flv to: /var/www/web12/web/php-site-monitor/files/tmp/2010-07-23_22-25-15
Moving file: test3.flv to: /var/www/web12/web/php-site-monitor/files/tmp/2010-07-23_22-25-15
Uploading file via FTP: test1.flv
KERBEROS_V4 rejected as an authentication type
FTP File Upload Completed: test1.flv
Uploading file via FTP: test2.flv
KERBEROS_V4 rejected as an authentication type
FTP File Upload Completed: test2.flv
Uploading file via FTP: test3.flv
KERBEROS_V4 rejected as an authentication type
FTP File Upload Completed: test3.flv
Uploads completed...
Deleting TEMP folder: /var/www/web12/web/php-site-monitor/files/tmp/2010-07-23_22-25-15
[root@linux1]#
Any recommendations?
Does anyone knows how to get rid of the message: "KERBEROS_V4 rejected as an authentication type" in the output or should I ignore it?