Check if wget finishes


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Check if wget finishes
# 1  
Old 12-30-2011
Check if wget finishes

how can you check if wget finishes?
i have this code to store the source of a website url into a variable:
Code:
source=$(wget --timeout=15 -qO - $site)


but this gets stuck sometimes

e.g., one site had a virus and it stopped the script
how can i check if wget finishes?




i tried to run wget in the command line for the site that stopped,
and it showed something like this at the end:

Code:
</div><!-- #wrapper -->

</body>
</html>


but then it just hangs there

like you can't type in the terminal, you have to exit out of it

do you know how to do a check for if wget is "stuck"?


thanks!

Last edited by jim mcnamara; 12-30-2011 at 08:44 AM.. Reason: code tags please
# 2  
Old 12-30-2011
Hi,
you may check for the presence of wget in the output of
Code:
ps -eaf

if still there after a reasonable time it may mean wget is stuck and you can kill wget‘s PID.

see ya
fra
# 3  
Old 12-30-2011
May be you can give a try at -T timeout option in wget...

--ahamed
# 4  
Old 12-30-2011
Quote:
Originally Posted by frappa
Hi,
you may check for the presence of wget in the output of
Code:
ps -eaf

if still there after a reasonable time it may mean wget is stuck and you can kill wget‘s PID.

see ya
fra
is this for the command line?

i am trying to use wget in a script and store it into a variable, for a list of domains, so for each domain i'm trying to find a way to determine how wget is stuck, and if its stuck then to skip that iteration

but i'm not sure how to check if wget is stuck
is there a command to check this that can be put into the script?
like does wget give a certain output if it is stuck?

---------- Post updated at 09:46 AM ---------- Previous update was at 09:45 AM ----------

Quote:
Originally Posted by ahamed101
May be you can give a try at -T timeout option in wget...

--ahamed
i'm currently using a timeout like:
source=$(wget --timeout=15 -qO - $site)

but it's not a timeout

like if there is a virus on the site, it doesn't timeout, wget still has an output but it is just "stuck", like it doesn't finish so that the next command can be entered

how can you check for this?

---------- Post updated at 09:48 AM ---------- Previous update was at 09:46 AM ----------

it seems like wget doesnt exit properly or something
it doesnt time out, just hangs
like it doesnt allow the next command

how can i check if wget is exiting properly or not in a script?
# 5  
Old 12-30-2011
Seeing how this command should run relatively quick, perhaps you could just background it:

Code:
source=$(wget -qO - $site &)

And then sleep for "X" amount of seconds or minutes and check to see if wget is still running. If so, kill the process.
# 6  
Old 12-30-2011
i found the problem, i think it kept on retrying, so i set tries=1 and then it exited

thanks for the responses

what i have is ok now

i was wondering, do you know how to check if wget returns an error code or a 301 redirect, etc.? like a 404 error, or 301 moved permanently, etc.? but if its complicated then nevermind, for now the basic wget check is enough

thanks
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Wait till any one child process finishes

Hi I am facing a problem in my ksh. My main script is calling 3 different child process in the background. I am using wait to finish all and then submit another 3 child processes. Now what i want is , whenever any one child process finishes ,i want to submit next one.so that parallel 3... (2 Replies)
Discussion started by: Sangu
2 Replies

2. UNIX for Advanced & Expert Users

CMD to check status of the server using Wget

Hi All, Using Wget I'm able to get the status of the server.....only when the server is completely down or up.... but problem here in script is Suppose if the server got hang I mean to say that if the server is taking long time to login, for example normally the server takes 3 seconds to login... (3 Replies)
Discussion started by: manohar2013
3 Replies

3. Shell Programming and Scripting

Check wget return code

hello check this script it jump to else part, in n both cases, (if files exist or not) wget $MIRROR/kkk.zip && wget $MIRROR/jjj.zip RC="$?" if ] then echo -e "$RED Ooops, Download links are broken...! $RESET" else echo -e "$GREEN Everything is fine, Cheers ... $RESET" fi (4 Replies)
Discussion started by: nimafire
4 Replies

4. UNIX for Dummies Questions & Answers

Problem with wget no check certificate.

Hi, I'm trying to install some libraries, when running the makefile I get an error from the "wget --no check certificate option". I had a look help and the option wasn't listed. Anyone know what I'm missing. (0 Replies)
Discussion started by: davcra
0 Replies

5. Shell Programming and Scripting

Deleting string within a file that finishes with .log

Hello, This is my first post. Nice forum! I have a file trls.results small exemple of content (actually the file can be very big): ./security/htaccess.htm ./security/ipcount.log ./adhoc/sql/datamod06.sql So there is 3 paths to 3 different files... I want to remove every string that has a... (9 Replies)
Discussion started by: Jacob106106
9 Replies

6. UNIX for Dummies Questions & Answers

Prints to screen when background process finishes

If I run "sleep 10&".. when that background process is done, is there a way for unix to print to screen to let me know? Thanks. (1 Reply)
Discussion started by: jmelai
1 Replies

7. Shell Programming and Scripting

wget to check an URL

I all, I wrote an script which starts a Weblogic server and waits until its loaded to deploy several apps. The way I checked was something like: while ; do wget --spider <URL>:<port>/console > /dev/null 2>&1 rc=$? done This works perfectly because it's an HTML site and when server is... (2 Replies)
Discussion started by: AlbertGM
2 Replies

8. Shell Programming and Scripting

Using wget and check for non-zero files

Hello, I'm using a shell script containing a wget-command that copies html-files from a website to my ISP-server. I therefore want to check if that file exist and also if the filessize is larger than e.g. 100 bytes. Probably it's done by using something like fileexist and filesize. The wget... (3 Replies)
Discussion started by: weatherboys
3 Replies

9. Shell Programming and Scripting

performing cleanup when a job finishes

The title sounds like an easy problem (maybe it is), however, the catch is that when a job 'A' is called inside a wrapper, the execution does not wait for 'A' to finish, but it goes on to the next line (right after kicking off 'A'). My question is, how will you keep the execution waiting for... (4 Replies)
Discussion started by: ChicagoBlues
4 Replies

10. Shell Programming and Scripting

send mail after script finishes running

Hi All, We now have a Log file which has time stamps of all the scripts ran. It has start time and end time. I now have a requirement to send mail to the Admin after the script finishes running. Can some one help me with a Script which will send mail with Start time and End time of the... (2 Replies)
Discussion started by: srikanthgr1
2 Replies
Login or Register to Ask a Question