Help in FTP'ing multiple files


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help in FTP'ing multiple files
# 8  
Old 12-01-2006
Thanks again Srikanthus2002. I modified the script as below and now it's working fine. I am able to copy multiple files in 2 seperate time stamped directories. Now, the problem lies in getting a mail after successful/failed FTP. I do not get any mail messege, even after files are copied properly.

Code:
#!/bin/ksh
HOME1=/home/sri
echo " 1"

cd /home/temp
mkdir ftp`date '+%Y%m%d'`
mkdir ftp_verify`date '+%Y%m%d'`

ftp -n server_ip << END_INPUT > /tmp/ftp_files.log 2>&1
user username password
cd $HOME1
prompt
lcd /home/tmp/ftp`date '+%Y%m%d'`
mget *.txt      # copies files correctly
lcd /home/tmp/ftp_verify`date '+%Y%m%d'`
mget *.txt      # copies files correctly
bye
END_INPUT

diff -w ftp`date '+%Y%m%d'` ftp_verify`date '+%Y%m%d'` > /dev/null 

if [ $? -ne 0 ]                                                               
then                                                                       
        echo "Error: Files are not successfully FTP'd"
mailx -r user@server.private.xyz.com -s \'"Files FTP failed'" annonymous@xyz.com  < /tmp/ftp_fail.msg

        exit 1
rm -r ftp_verify`date '+%Y%m%d'`

mailx -r user@server.private.xyz.com -s \'"Files FTP successful'" annonymous@xyz.com  < /tmp/ftp_succ.msg

fi 
exit 0


Last edited by vgersh99; 12-01-2006 at 05:10 PM..
# 9  
Old 12-01-2006
<ModeratorHat>
berlin_germany,
pls do use vB Codes when posting to ease the readibility and proper formating.
</ModeratorHat>
# 10  
Old 12-01-2006
It looks like you are missing an "else".
Code:
if [ $? -ne 0 ]                                                               
then                                                                       
        echo "Error: Files are not successfully FTP'd"
        mailx -r user@server.private.xyz.com -s \'"Files FTP failed'" annonymous@xyz.com  < /tmp/ftp_fail.msg
        exit 1
else
        rm -r ftp_verify`date '+%Y%m%d'`
        mailx -r user@server.private.xyz.com -s \'"Files FTP successful'" annonymous@xyz.com  < /tmp/ftp_succ.msg
fi

Your code would currently exit on an error, and do nothing on success.
# 11  
Old 12-01-2006
Even after using if....then....else....fi in my code I am not getting any mail messege. I think, somehow "mailx -s" in above script is not working. I don't know, why? Because the same mail command is successful in the script, when I use ftp steps like,

`ftp -vin <<- END_INPUT > tmp/ftp_files.log 2>&1
.....
......
bye
END_INPUT`

But, using this the problem is that mget *.txt, mput *txt is not working. It only works for a single file transfer like, put, get etc. Can anybody please suggest a way to do that?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

FTP-ing files from Windows server to UNIX server

I need to transfer files from a Windows server to the Unix server and have to run some shell script on it to get the required output. Is it possible to transfer files from Windows server to unix server through any shell script? If so can you please help me with the details. Thanks in... (8 Replies)
Discussion started by: ssk250
8 Replies

2. Shell Programming and Scripting

ftp'ing multiple files to the remote server

unix shell script (2 Replies)
Discussion started by: giridhar276
2 Replies

3. Shell Programming and Scripting

FTP'ing the zipped file

Hi, I need to have a shell script that FTP's a zipped file from a particular location. I have some path and inside that path i will have folders like x_timestamp and inside x_timestamp there may many folders based upon events like y_111,y_222,y_333.Inside each event there will be another... (3 Replies)
Discussion started by: weknowd
3 Replies

4. Shell Programming and Scripting

FTP multiple files from multiple directories

I have multiple files that starts as TRADE_LOG spread across multiple folders in the given structure.. ./dir1/1/TRADE_LOG*.gz ./dir2/10/TRADE_LOG*.gz ./dir11/12/TRADE_LOG*.gz ./dir12/13/TRADE_LOG*.gz when I do ftp uisng mput from the "." dir I am getting the below given error mput... (1 Reply)
Discussion started by: prasperl
1 Replies

5. Shell Programming and Scripting

grep'ing and sed'ing chunks in bash... need help on speeding up a log parser.

I have a file that is 20 - 80+ MB in size that is a certain type of log file. It logs one of our processes and this process is multi-threaded. Therefore the log file is kind of a mess. Here's an example: The logfile looks like: "DATE TIME - THREAD ID - Details", and a new file is created... (4 Replies)
Discussion started by: elinenbe
4 Replies

6. UNIX for Dummies Questions & Answers

FTP'ing EBCDIC Characters from Mainframe

Hi All, I am new to this site, I have a requirement where in i have to FTP a file from mainframe to Unix box. The catch here is there are few Spanish characters like N with tilde(~) and a with ` etc., all other characters are coming fine but those mentioned above are not coming in a proper... (1 Reply)
Discussion started by: harikiranr
1 Replies

7. Shell Programming and Scripting

size of a file that iam ftp ing

Hi, I want to compare the size of the files in my local machine before ftp ing it and the size of the file in the remote machine i.e after ftping . SO that the ftp is successful . (3 Replies)
Discussion started by: dineshr85
3 Replies

8. UNIX for Advanced & Expert Users

Dynamically ftp'ing a file

Hi, I am having unix script that passes argument value to script. The script finds the file and keeps it in a directory. I need to ftp this file to another server. Please guide me how to acieve this. I am able to connect to ftp server but i am not able to use the unix argument in the ftp... (0 Replies)
Discussion started by: pyaranoid
0 Replies

9. Shell Programming and Scripting

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”,... (1 Reply)
Discussion started by: berlin_germany
1 Replies

10. IP Networking

Ftp'ing thru a Iptables NAT Masquerade

Greetings to all. My new firewall is giving me one hell of a problem. I'm running iptables and masquerading my intranet thru NAT. But here is the problem. Whenever I try to FTP to a server outside of my lan I get a 500 illegal port error. I've come to the conclusion that NAT is... (2 Replies)
Discussion started by: phrater
2 Replies
Login or Register to Ask a Question