removing files after ftping

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting removing files after ftping
# 1  
Old 01-31-2008
removing files after ftping

Hi All,

I'm trying to write script to ftp some files and then need to remove these files from server.
Is there any way to keep the condition that the file should be removed only after successfully transfered to the destinatino server?
If in case, the file isn't been transferd, it should not be removed.

Thanks in advance.

# 2  
Old 02-25-2008
Can anyone plz help/advise?
# 3  
Old 02-25-2008
did you try to check the status of transfer using '$?' ?
# 4  
Old 02-26-2008
Hi manikantants,
I'm dealing with ftp for the first time. I'm not sure how this status check is done? Can u plz let me know.. Even, I'll try to search for it.
# 5  
Old 02-26-2008
'$?' will give the exit status of previous command.
So in case of ftp also you can check this exit status. If it is not equal to zero, that means ftp was not successfull.

following lines may help you. I haven't tested this.
Please test it properly before using.

ftp -n << EOF
user username
put filename

if [ $? -eq 0 ]
#do the required on successfull transfer
#do the required on failure
# 6  
Old 02-26-2008
Thanks a ton!!! Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Find and removing the old files and zipping the files using shell script

Hi, I am trying to removing the old files which were older than 10 days and same g zipping the files using the shell script. script was return as follows. find /jboss7_homes/JBOSS7/SKYLIV??/SKYLIV??_CRM/jboss-eap-7.0/standalone/log -mtime +10 -type f | xargs rm -f find /cer_skyliv??/log... (6 Replies)
Discussion started by: venkat918
6 Replies

2. Shell Programming and Scripting

FTPing files from unix server to windows server

Hi, Below is the script which ftps the file from unix server and putting in a different directory(but on unix server) How can i ftp the files from unix server and to place in a secure location on windows server? what changes needs to be done to the below script? How can this be... (1 Reply)
Discussion started by: venkatesht
1 Replies

3. UNIX for Dummies Questions & Answers

ftping a Zip file

i want to sftp a .zip file.when i am doing get is getting copied to my home folder. but on clicking on my home folder to open it i am getting error message as "Unable to unarchive into <homefolder> name" How to sftp the Zip file Thanks (1 Reply)
Discussion started by: bmrout007
1 Replies

4. UNIX for Dummies Questions & Answers

How to remove junk (^) character while FTPing

Hi All, I have been trying to FTP some data files from Windows directory to a UNIX server. The txt file in the windows contails the following data: "111~XYZ~1~Contact person’s phone number~COMMENTS~~~~" but the same line is appearing as "111~XYZ~1~Contact person^s phone number~COMMENTS~~~~"... (8 Replies)
Discussion started by: vkumbhakarna
8 Replies

5. UNIX for Dummies Questions & Answers

Script for FTPing files to mainframe GDG

Hi, Request Unix gurus to kindly share a script which FTPs multiple files from Unix to a Mainframe GDG. The script should check for oldest file named as 'abc*.txt' in a directory '/dir/child'. FTP that file to MF, then remove the file from unix and then look for the next oldest file to be... (1 Reply)
Discussion started by: dsrookie
1 Replies

6. UNIX for Dummies Questions & Answers

FTPing from XP to Solaris

Hello. I'm new to Unix. I've got a SUN Ultra 10 running Solaris 5.7 and I'm trying to FTP to it from my XP PC. My PC has an IP address of and a Subnet of I'm connected to the Sun machine with a crossover cable. I type "ifconfig hme0" in a shell window (as... (3 Replies)
Discussion started by: dtferreira
3 Replies

7. Shell Programming and Scripting

Error in ftping script

Hi all , Can u please help me in this. I tried to just login server through the below script SERVER="Server_NAME" USER="i am user" PASSWD="mypassword" ftp -in $SERVER<<EOF user $USER $PASSWD mkdir Chanakya #To create directory with my name in $HOME ls > list put list bye... (5 Replies)
Discussion started by: Chanakya.m
5 Replies

8. UNIX for Dummies Questions & Answers

Ftping through unix script

Hi all, I am trying to write a script to connect to remote host and ftp some files there. The problem i am facing is,I dont know how to specify username and password for remote host through scripting. and even if i am able to connect to remote host,then how should i execute commands like mput... (17 Replies)
Discussion started by: Shiv@jad
17 Replies

9. UNIX for Advanced & Expert Users

FTPing over COM port ???

Hello. Can someone please help, or give me any advice. The company I work for has a unix machine and works over the com port rather than IP. We need to retrieve some files from it onto another unix machine and we are trying to get an ftp program to work, does anyone know any ftp programs that... (1 Reply)
Discussion started by: badge
1 Replies

10. UNIX for Dummies Questions & Answers

FTPing backup files to another server

I am running a hot backup of my database every night within our cronjob. Recently I got burned because the tape which holds my backups became corrupt. I am setting up another Sun box to hold my backups as well as writing them to tape. I know dumb error on my part. My question is what will I... (10 Replies)
Discussion started by: fredlucas3
10 Replies
Login or Register to Ask a Question