LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 02-21-2005, 08:42 PM   #1
vwvr9
Member
 
Registered: Feb 2005
Distribution: OpenSuse 10.1 / Centos 4.4
Posts: 60

Rep: Reputation: 15
> Ftp With Exit Status, Ftp with exit status


Hi guys,

I'm wrinting a dropbox script for my client. I'm supposed to conenct to their server and get files everyday for processing and then delete the file off the server. The problem i face now is that the connection is not very stable.
To work around this I want to be able to build error checking into my script so that if the connection fails the script will run again and try to recconect. And also based on the exit status i will be able to know if i can delete the files off the server.
My ques is, how do I check the exit status for the script below. I'm open to the idea of using a different client like ncftp if required.

This if the connection method used by the client's side.

Code:
ftp -niv ftp.example.com
user user1 [prompts for password]
user anonymous@ftp.example.com
user user1 [prompts for password]
This is is the script i've written.

Code:
# Ftp
hostname="ftp.example.com"
username1="ftpuser"
username2="anonymous@ftp.example.com"
password1="xxxxxxx"
password2="example@example.com"

echo
echo ----------------------------------------------------------
echo Ftp script started at `date`
echo ----------------------------------------------------------
echo

echo
echo ----------------------------------------------------------
echo STAGE 1 - Getting files from client
echo ----------------------------------------------------------
echo

cd $INBOX

ftp -inv $hostname << EOF
quote USER $username1
quote PASS $password1
quote USER $username2
quote PASS $password2
quote USER $username1
quote PASS $password1
passive
cd outgoing
pwd
type binary
mget *
bye
EOF
 
Old 02-22-2005, 04:18 AM   #2
Artanicus
Member
 
Registered: Jan 2005
Location: Finland
Distribution: Ubuntu, Debian, Gentoo, Slackware
Posts: 827

Rep: Reputation: 31
imho wget is sufficient in ftp, and has pretty good retry features for working on shady phonelines.. (; Maybe you could have wget try and download the files, retrying a few times, so you will most likely get complete files, and then your script initializes a normal ftp client to do the removing..

Just an idea..
 
Old 02-22-2005, 07:28 AM   #3
hw-tph
Senior Member
 
Registered: Sep 2003
Location: Sweden
Distribution: Debian
Posts: 3,032

Rep: Reputation: 58
I use expect for writing FTP scripts. It is very effective, and writing scripts is made very easy by the autoexpect script that comes with the distribution. It will capture inputs and outputs and put together a script that will mimic what you just did.


Håkan
 
Old 02-22-2005, 09:14 PM   #4
vwvr9
Member
 
Registered: Feb 2005
Distribution: OpenSuse 10.1 / Centos 4.4
Posts: 60

Original Poster
Rep: Reputation: 15
Quote:
Originally posted by hw-tph
I use expect for writing FTP scripts. It is very effective, and writing scripts is made very easy by the autoexpect script that comes with the distribution. It will capture inputs and outputs and put together a script that will mimic what you just did.


Håkan
Know where i can get it?
 
Old 02-23-2005, 02:53 AM   #5
Artanicus
Member
 
Registered: Jan 2005
Location: Finland
Distribution: Ubuntu, Debian, Gentoo, Slackware
Posts: 827

Rep: Reputation: 31
http://expect.nist.gov/

My slackware had it installed allready tho, so maybe you have it too?
 
  


Reply



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
exit status naflan Programming 2 10-22-2004 12:22 PM
exit status 17 kppp joshy Mandriva 3 10-08-2004 07:07 AM
error exit status 30 debian_dummy Debian 2 09-21-2004 10:26 PM
pppd exit status 1 wolfe2554 Linux - Networking 2 04-14-2004 12:15 AM
Trapping an exit status chrisk5527 Linux - General 3 09-12-2003 09:02 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 01:49 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration