UNIX Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOperating SystemsUNIX Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old January 11th, 2005, 05:30 PM
seeley seeley is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Posts: 1 seeley User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Need a simple shell command loop

I want to download multiple files to my server.
have been using
lwp-download <url> [<local file>]
command.
Want a simple loop where the above command is
repeated on a list of url's.
Would need a command that would escape and proceed
to next url if a fault occurred (like unable to connect, etc)
This is on a Ensim Linux server
Kernel 2.4.22

Any help would be appreciated

Sincerely,
Ray

Reply With Quote
  #2  
Old January 14th, 2005, 06:34 AM
zby zby is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jul 2003
Location: Prague, Czech Republic
Posts: 825 zby User rank is Second Lieutenant (5000 - 10000 Reputation Level)zby User rank is Second Lieutenant (5000 - 10000 Reputation Level)zby User rank is Second Lieutenant (5000 - 10000 Reputation Level)zby User rank is Second Lieutenant (5000 - 10000 Reputation Level)zby User rank is Second Lieutenant (5000 - 10000 Reputation Level)zby User rank is Second Lieutenant (5000 - 10000 Reputation Level)zby User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 6 Days 16 h 4 m 55 sec
Reputation Power: 65
Well, I've written the below code 'right off the bat'. Hopefuly no errors occure.
Also the code is well simple. In case of fine-tunning I recommend using perl's LWP::UserAgent.

If the URL is not accessible the lwp-download exits leaving the $? variable set to nonzero (default command return code) and no output file is created.

Code:
#!/bin/sh

URL1="http://srv1"
URL2="http://srv2"
FILES="one.html two.html three.html four.pdf"

for i in $files
do
   if [ $? -eq "0" ]
    then
       LINK=$URL1/$i
    else
      LINK=$URL2/$i
   fi
   # echo $LINK
   lwp-download $LINK $i
done

exit 0


Hope it'll work for you.

Last edited by zby : January 14th, 2005 at 06:37 AM.

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsUNIX Help > Need a simple shell command loop


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway