from:lu02 to:ax07@noaa.gov subject:get_messages #!/bin/bash CR=$'\r' configPath="/var/www/html/cfg/config.ini" FTPUSER=`grep 'FTPUser[ ]*=[ ]*' $configPath` PASSWORD=`grep 'FTPPassword[ ]*=[ ]*' $configPath` inbox=`grep 'inbox[ ]*=[ ]*' $configPath` mailUser=`grep 'mailUser[ ]*=[ ]*' $configPath` FTPHost=`grep 'FTPHost[ ]*=[ ]*' $configPath` FTPPath=`grep 'FTPPath[ ]*=[ ]*' $configPath` # removes empty spaces mailUser=${mailUser//[[:blank:]]/} PASSWORD=${PASSWORD//[[:blank:]]/} inbox=${inbox//[[:blank:]]/} FTPHost=${FTPHost//[[:blank:]]/} FTPPath=${FTPPath//[[:blank:]]/} FTPUSER=${FTPUSER//[[:blank:]]/} # removes double quotes inbox=${inbox//\"/} mailUser=${mailUser//\"/} FTPHost=${FTPHost//\"/} FTPPath=${FTPPath//\"/} PASSWORD=${PASSWORD//\"/} FTPUSER=${FTPUSER//\"/} IFSBak=$IFS IFS="=" tokens=( $mailUser ) mailUser=${tokens[1]%$CR} tokens=( $PASSWORD ) PASSWORD=${tokens[1]%$CR} tokens=( $inbox ) inbox=${tokens[1]%$CR} tokens=( $FTPHost ) FTPHost=${tokens[1]%$CR} tokens=( $FTPPath ) FTPPath=${tokens[1]%$CR} tokens=( $FTPUSER ) FTPUSER=${tokens[1]%$CR} IFS=$IFSBak if [ ! -d "$inbox/$mailUser/tmp" ]; then mkdir -p $inbox'/'$mailUser'/tmp' chgrp www-data $inbox/$mailUser chmod 777 $inbox/$mailUser chown www-data $inbox/$mailUser'/tmp' chgrp www-data $inbox/$mailUser'/tmp' chmod 777 $inbox/$mailUser'/tmp' chown www-data $inbox/$mailUser'/tmp' fi #ncftpget -u $FTPUSER -p $PASSWORD -DD $FTPHost $inbox'/'$mailUser $FTPPath'/'$mailUser/inbox/* cd $inbox/$mailUser'/tmp' ftp -4 -invp $FTPHost </dev/null