Solved

Check whether FTP is successful or not, in a Unix shell script

Posted on 2004-08-21
7
1,846 Views
Last Modified: 2013-12-26
I want to write a Unix shell script which will ftp a file from one server to another.  I want to check whether the FTP is successful or not.  After the FTP is complete, I would like to check the cksum of local and remote file, to compare whether the transfer was successful.  I dont want to use ssh.  How can I do this?

Also, if I can print the status of each of the statements below, then it would be great.

ftp username password
<check whether you are able to login, or is there a failure>
lcd /home/abcd
<check whether this folder exists>
cd /home/efgh
<check whether this folder exists>
put a_local.txt  a_remote.txt
<check the status here, whether file was completely or partially transferred>
0
Comment
Question by:paragpjoshi
7 Comments
 

Author Comment

by:paragpjoshi
ID: 11863543
Someone please help ASAP
0
 
LVL 5

Accepted Solution

by:
ITcrow earned 500 total points
ID: 11865819
#!/bin/sh

{ echo "
open ftp.someserver.wherever
user anonymous anonymous@mars.nodomain
hash
lcd /home/abcd
pwd
cd /home/efgh
pwd
put a_local.txt  a_remote.txt
close
"
} | ftp -inv 2>&1 | tee ftp_session.log

Go ahead, add any kind of commands in it, which you normally use in
interactive FTP.

In addition you are getting a complete session log "ftp_session.log"
0
 
LVL 2

Expert Comment

by:rajeshp_69
ID: 12074048
It'll be highly impossible to interpret the ftp session and check the conditions. If you want to achieve the same try with rsh or remsh commands. Check the man pages and you can achieve the same. If you need any help regarding rsh/remsh then let me know.

Bye
0
 

Expert Comment

by:lb2020
ID: 33162897
Hi folks,
 I have the same requirement i need to trap the errors in FTP transfer using unix .Iam new to unix please help me out if u have any sample code regarding this.

I also need to check whether ftp successful or not..

Thanks,
Lenin

0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Windows Drag & Drop Location 2 85
WinWaitActive parameters 12 31
maxBlock challenge 30 100
Prevent this page from creating additional dialogs. 3 260
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now