|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
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
|
|||
|
|||
|
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 |
|
#2
|
|||
|
|||
|
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. |
![]() |
| Viewing: Dev Shed Forums > Operating Systems > UNIX Help > Need a simple shell command loop |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|