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



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Copying files from a remote server to local system with cygwin patwa UNIX for Dummies Questions & Answers 3 06-12-2008 07:49 AM
Find match in two diff file - local srv and remote server amir07 Shell Programming and Scripting 0 03-07-2008 10:23 AM
Transfer file from local unix server to remote server indira Shell Programming and Scripting 2 05-03-2007 06:35 AM
Transfer file from local unix server to remote server indira HP-UX 2 05-02-2007 05:15 PM
executing a remote location script from local server srivsn Shell Programming and Scripting 2 02-28-2006 03:16 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #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!
  #2 (permalink)  
Old 12-19-2006
berlin_germany berlin_germany is offline
Registered User
  
 

Join Date: Nov 2006
Posts: 17
Following FTP steps has solved the problem.

ftp -vn $HOST <<END_SCRIPT > $LOG/delete_files.log 2>&1
quote USER username
quote PASS password
bin
prompt off
cd $PICKUP
mget *
bye
END_SCRIPT

EXIT_STATUS=$?
if [[ $EXIT_STATUS -ne 0 ]]
then
mailx -s \'"Files FTP failed'" user@xyz.com < $MSG/ftp_fail.msg
exit 1
else
mailx -s \'"Files FTP successful'" user@xyz.com < $MSG/ftp_succ.msg
fi
exit 0
  #3 (permalink)  
Old 12-20-2006
happyv happyv is offline
Registered User
  
 

Join Date: Sep 2006
Posts: 209
Quote:
Originally Posted by berlin_germany
Following FTP steps has solved the problem.

ftp -vn $HOST <<END_SCRIPT > $LOG/delete_files.log 2>&1
quote USER username
quote PASS password
bin
prompt off
cd $PICKUP
mget *
bye
END_SCRIPT

EXIT_STATUS=$?
if [[ $EXIT_STATUS -ne 0 ]]
then
mailx -s \'"Files FTP failed'" user@xyz.com < $MSG/ftp_fail.msg
exit 1
else
mailx -s \'"Files FTP successful'" user@xyz.com < $MSG/ftp_succ.msg
fi
exit 0
but the ftp failed error message not work...
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 03:43 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0