The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 12-13-2006
berlin_germany berlin_germany is offline
Registered User
  
 

Join Date: Nov 2006
Posts: 17
FTP multiple files from remote server to local server

Hi,

I am facing a weired problem in my FTP script. I want to transfer multiple files from remote server to local server everyday, using mget * in my script. I also, want to send an email for successful or failed FTP. My script works for file transfer, but it don't send any mail. There is somthing wrong with mailx option, I don't know what.

If I use the FTP part of the script like below, mailx works fine, but then mget is not working (only get is working) and no files are transfered.

`ftp -vin <<- END_INPUT > $LOG/ftp_files.log 2>&1
open $DEVICE
user $LOGIN $FTPPASS
cd $PICKUP
prompt off
mget *.txt
quit
END_INPUT`

The original script is below:

#!/bin/ksh

export DROPOFF=/data/local/temp
export PICKUP=/data/remote/temp
export MSG=/data/local/temp
export IND_FILE=/data/local/temp
export LOG=/data/local/temp
export LOGIN=username
export FTPPASS=password
export DEVICE=remoteserver

cd $DROPOFF

ftp -vin <<- END_INPUT > $LOG/ftp_files.log 2>&1
open $DEVICE
user $LOGIN $FTPPASS
cd $PICKUP
prompt off
mget *.txt
quit
END_INPUT
EXIT_STATUS=$?


if [ $EXIT_STATUS -ne 0 ]
then
echo "[%s - %s]ERROR: FTP failed with an exit status of %s\n" \
%0 "$(date +'%x %X')" $EXIT_STATUS
mailx -r mlqis4s@server.private.company.com -s \'"Files FTP failed'" user@company.com < $MSG/ftp_fail.msg
exit 1
fi
echo mailx -r mlqis4s@server.private.company.com -s \'"Files FTP successful'" user@company.com < $MSG/ftp_succ.msg

exit 0

Please anybody have a clue to solve that? Thanks in advance!