Solved

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

Posted on 2004-08-21
7
2,016 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
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.
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

729 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