Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 06-01-2009, 07:42 AM   #1
Registered: Jun 2009
Location: Spain
Distribution: Various, Ubuntu, Fedora, Open Solaris, Solaris, RHEL, CentOS
Posts: 64

Rep: Reputation: 16
Automated Download Problem - shell ftp vs Perl

Hi All

I hope someone may be able to help me resolve a problem I have been having.

I recently set up an automated shell script (bash on Ubuntu 8.10) to download new files from a server using ftp. Unfortunately the other end of the link is not terribly stable (and there is nothing I can do about this) which has resulted in the script hanging sometimes and then being kicked off again at the time set in the crontab.

This has resulted in multiple hung sessions taking up all the system resources.

The offending section of code is given below.

for file in $(echo $filelist)
  if [-f $file]
    echo $file already exists: skipping
    echo opening connection
    /usr/bin/ftp -ni $R_FTP <<-EOS 1>>tfr.log 2>>tfr.err
    quote USER $USR
    quote PASS $PSWD
    get $file .$file
    echo $file retreived
    mv .$file $file
I'd like to know if there is a way I can force an exit if the connection hangs or alternatively if something like the Perl Net::FTP can handle these sorts of errors internally.

I really appreciate any advice!

Last edited by emmalg; 06-01-2009 at 07:48 AM. Reason: Incomplete
Old 06-01-2009, 08:14 AM   #2
LQ Newbie
Registered: Apr 2008
Location: Hampshire, UK
Distribution: None
Posts: 27

Rep: Reputation: 16
Net::FTP does have a read and write timeout, but you might like to try wget which seems to do everything!

Old 06-01-2009, 09:40 AM   #3
Registered: Jun 2009
Location: Spain
Distribution: Various, Ubuntu, Fedora, Open Solaris, Solaris, RHEL, CentOS
Posts: 64

Original Poster
Rep: Reputation: 16
Thumbs up

Cheers Steve! Funnily enough I've actually spent most of my time since posting this working on an alternative using wget, I'm glad to know (fingers crossed) that it should have solved the time out issues!

Old 06-01-2009, 12:34 PM   #4
LQ Guru
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288
I think lftp has a timeout setting as well.


automated, ftp, perl

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Perl script to download the files from FTP server peddip Linux - Server 4 03-23-2009 09:49 AM
shell or perl script to change ftp user password vivek rai Linux - Newbie 4 03-15-2009 01:09 PM
automated FTP shell script RedOctober45 Linux - Software 1 01-09-2008 08:58 AM
How to prevent Automated download software vhh Programming 7 08-07-2005 03:17 AM
How to write a shell script to download a file via FTP? guarriman Linux - General 4 12-21-2004 09:31 AM > Forums > Linux Forums > Linux - Software

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

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