LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
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.

Notices


Reply
  Search this Thread
Old 06-01-2009, 07:42 AM   #1
emmalg
Member
 
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.

Code:
for file in $(echo $filelist)
do
  if [-f $file]
    then
    echo $file already exists: skipping
  else
    echo opening connection
    /usr/bin/ftp -ni $R_FTP <<-EOS 1>>tfr.log 2>>tfr.err
    quote USER $USR
    quote PASS $PSWD
    binary
    get $file .$file
    close
    bye
    EOS
    echo $file retreived
    mv .$file $file
  fi
done
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
stevexyz
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!

Steve
 
Old 06-01-2009, 09:40 AM   #3
emmalg
Member
 
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!

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

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


Reply

Tags
automated, ftp, perl



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

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 01:40 AM.

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