nixCraft Linux Forum

nixCraft

Linux Tech Support Forum

If error repeat the download?

This is a discussion on If error repeat the download? within the Shell scripting forums, part of the Development/Scripting category; I have a script which downloads like 10 xml files from free feed hosting site. And script has something like ...


Go Back   nixCraft Linux Forum > Development/Scripting > Shell scripting

Register FAQ Members List Calendar Forgotten your password? Mark Forums Read
  #1 (permalink)  
Old 10-05-2006, 11:01 PM
Junior Member
User
 
Join Date: Jun 2006
Posts: 21
Rep Power: 0
karabaja
Default If error repeat the download?

I have a script which downloads like 10 xml files from free feed hosting site.
And script has something like this
Code:
wget http://www.feedurl.com/rss.xml
mv rss.xml filename.xml
wget http://www.feedurl.com/filename.xml
etc.
some of them are named rss.xml and I can't change that so I use mv to rename them to what I need them to be named. Some of them I don't need renaming so they are downloaded as is.

But the problem is that this feed hosting site has high loads often and outputs just error instead of the feed. And if I try to download same feed like 10 seconds later it will work sometimes.
The problem is I can't check on it all the time if it downloaded them all ok or got some errors.

So I was wondering is there a way and how. To include like error search in the script so that it searches the rss.xml or filename.xml for errors after it is downloaded and if it finds errors to repeat download with 10 seconds delay. This is part of the error that is written in files if they weren't retrieved properly:
Code:
The remote server returned an error
so I was hoping to set up something like search for the above and if found repeat
Code:
wget wget http://www.feedurl.com/rss.xml
after 10 seconds.
but I have no idea what commands would do that if possible at all.

And would the rest of the script wait for first process to finish before continuing or would I have to split each file in separate script.

Thanks in advance and thx for all helpful replies on my previous threads.
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 10-06-2006, 01:36 AM
nixcraft's Avatar
Never say die
User
 
Join Date: Jan 2005
Location: BIOS
My distro: Ubuntu
Posts: 1,036
Rep Power: 10
nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute
Default

Use exit status of wget. If it is zero command is successful else failed to download rss.

Code:
wget http://someurl.com/feed/
if [ $? -ne 0 ];
 echo "Failed " 
else 
 echo "Done"
fi
May be in for loop...
Code:
#!/bin/sh
URLS="http://some.com/rss http://u.com/feed http://abc.com/atom.xml"
for u in $URLS
do
wget $u
if [ $? -ne 0 ];
 echo "$u - Failed " 
 # add more error logic 
 # try to repeat download one more time
 wget $u
else 
 echo "$u - Done"
fi
done
__________________
Vivek | My personal blog
Linux Evangelist
Play hard stay cool
Reply With Quote
  #3 (permalink)  
Old 10-06-2006, 05:11 PM
Junior Member
User
 
Join Date: Jun 2006
Posts: 21
Rep Power: 0
karabaja
Default

Thx but I am not sure I understood that. The thing is that it on most feeds it will never fail downloading. But rather download file with just errors. That's because I use another site to group feeds together in one feed. And site that hosts joined feeds works fine so it just downloads a feed with errors reported for stand alone feeds that are a part of it.
Reply With Quote
  #4 (permalink)  
Old 10-10-2006, 03:32 AM
sweta's Avatar
Contributors
User
 
Join Date: Feb 2005
Location: New Delhi
My distro: Suse, RHEL, Vista
Posts: 154
Rep Power: 4
sweta will become famous soon enough
Default

Please post your existing script so that we can provide solution or at least give you some suggestion
__________________
Friends - v-nessa - missyAdmin - LinuxChix
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads

Thread Thread Starter Forum Replies Last Post
gcc 3.4.6 rpm download chiku Linux software 2 05-18-2007 05:21 PM
Invalid ICMP type 3 code 3 error to a broadcast -samba error raj Linux software 0 07-09-2006 05:38 AM
Download with timer? marinm Shell scripting 6 01-23-2006 12:53 AM
Linux desktop download rogy Linux software 2 01-05-2006 08:06 PM


All times are GMT +5.5. The time now is 06:39 PM.


Powered by vBulletin® Version 3.7.4 - Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36