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
read list of filenames from text file and remove these files in multiple directories fxvisions Shell Programming and Scripting 5 08-07-2008 04:59 PM
How can I rename multiple files depending on a string occuring in the filenames? karman UNIX for Dummies Questions & Answers 6 05-22-2007 03:29 PM
Getting a list of filenames of moved files chengwei Shell Programming and Scripting 3 04-23-2007 04:25 AM
Help in FTP'ing multiple files berlin_germany Shell Programming and Scripting 10 12-01-2006 05:48 PM
Script to backup multiple files and amend their filenames m223464 Shell Programming and Scripting 5 11-25-2005 06:30 AM

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 11-26-2006
berlin_germany berlin_germany is offline
Registered User
  
 

Join Date: Nov 2006
Posts: 17
FTP'ing files with filenames in mail messege

Hi,
I have created the following FTP script, which transfers daily “.txt” files from remote server in to a timestamped folder on local server. Once all files are FTP’ed, it then deletes files from remote server. When files are FTP’ed, I get a mail messege like, “Files are successfully transfered”, which I have hard-coded in “ftp_succ.msg” file. My problem is that I want to include names of FTP’ed files in this messege. Now, names of files FTP’ed can change everyday, so I can’t use a hard-coded pattern messege. Instead I want to be done that by FTP script itself. Can anybody please suggest me, how to do that?

####################################################
# Set local variables
####################################################
export DROPOFF=/temp1
export PICKUP=/temp2
export MSG=/temp1/ftp_messege
export LOG=/temp1/ftp_log
export LOGIN=username
export FTPPASS=password
export DEVICE=remoteserver

####################################################
# FTP'ing files from remoteserver to localserver
####################################################

cd $DROPOFF
mkdir ftp`date '+%Y%m%d'`
cd ftp`date '+%Y%m%d'`

`ftp -vin <<- END_INPUT > $LOG/ftp_files.log 2>&1
open $DEVICE
user $LOGIN $FTPPASS
cd $PICKUP
mget * .txt
# mget *.* would get all files from current directory.
# By default, prompting would be enabled; if you wish to get all files without being
# prompted, use the "prompt" command to disable/enable prompting.
mdelete * .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 xyz@localserver.annonymous.com -s \'"Files FTP failed'" user@annonymous.com < $MSG/ftp_fail.msg
exit 1
fi

####################################################
# Notifying successful FTP of files
####################################################

mailx -r xyz@localserver.annonymous.com -s \'"Files FTP complete to localserver successfully'" user@annonymous.com < $MSG/ftp_succ.msg

exit 0
  #2 (permalink)  
Old 11-27-2006
ziminski ziminski is offline
Registered User
  
 

Join Date: Mar 2006
Posts: 5
Basically you have the answer in the ftp_log file. Either cat it into the mail message, or grep out the parts from the log and add that to the mail message. I typically send the whole ftp log sd it's usually not very big.
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 05:10 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