Check wget return code


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Check wget return code
# 1  
Old 10-21-2014
Check wget return code

hello
check this script it jump to else part, in n both cases,
(if files exist or not)

Code:
wget $MIRROR/kkk.zip && wget $MIRROR/jjj.zip
RC="$?"
if [[ "$RC" -ne 1 ]]
then
echo -e "$RED Ooops, Download links are broken...! $RESET"
else
echo -e "$GREEN Everything is fine, Cheers ... $RESET"
fi


Last edited by bartus11; 10-21-2014 at 01:50 PM.. Reason: Please use [code][/code] tags.
# 2  
Old 10-21-2014
What are you expecting?
What do you mean by both cases?
# 3  
Old 10-21-2014
Quote:
Originally Posted by nimafire
Code:
if [[ "$RC" -ne 1 ]]

This is true whenever "$RC" is not 1 ("ne" = "not equal").

You probably mean:

Code:
if [ $RC -eq 0 ] ; then
     echo "success"
else
     echo "failed"
fi

because a return code of "0" usually means success, everything else means some error condition.

I hope this helps.

bakunin
# 4  
Old 10-21-2014
@bakunin

You just reversed the terms but OP condition logic is still the same, unless that it gets something else than a 0 or 1.
# 5  
Old 10-21-2014
why not just wget http://url1 http://url2 instead of running wget twice?

Also, if the page redirects to an error page instead of giving a proper 404, wget will not detect an error.

Last edited by Corona688; 10-21-2014 at 04:01 PM..
This User Gave Thanks to Corona688 For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to return from background process and check if it is running or not?

Hi Team, i am executing 3 scripts in background from 1 script and i want to send a message once the script gets completed.these scripts usually takes 1 hr to complete. My sample script is below, Vi abc.sh sh /opt/data/Split_1.sh & sh /opt/data/Split_2.sh & sh /opt/data/Split_3.sh & ... (3 Replies)
Discussion started by: raju2016
3 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 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: 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... (5 Replies)
Discussion started by: vanessafan99
5 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

Find: return code check

Hi, I've a find command like, find /abcd/efgh -name "xxxx" 2> /dev/null > file1 what would be the condition to check if this returns none(means if the file "xxxx" is not present) ???? I tried checking with $? and it returns 72 to me but even the file is present also it returns... (6 Replies)
Discussion started by: skcvasanth
6 Replies

6. Shell Programming and Scripting

check if return value is blank

Hi, i am trying to get the no of users using nofActUsers=$(echo /usr/sbin/lsof -l | grep "/mast/data/users" ) it will return blank, if the user does nto have permissions to run the script. Now I need to check if the valueis blank i have route to another script else the user has to... (1 Reply)
Discussion started by: Satyak
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. UNIX for Dummies Questions & Answers

to check if file is empty or not and return a non zero value

Hi All, I am new to unix worldd . I need to check a file1 if its empty or not. If its empty then return a non zero value say 99 could you pls let me know the perl script for this. (2 Replies)
Discussion started by: mavesum
2 Replies

9. 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

10. UNIX for Dummies Questions & Answers

to pick up the Return Code ( RC) from the mailx command and return it to SAS uisng 's

Hi All, Can anyone please let me know the syntax / how to pick up the Return Code ( RC) from the mailx command and return it to SAS uisng 'system()' function and '${?}'. I am in a process to send the mail automatically with an attachment to bulk users. I have used 'Mailx' and 'Unencode'... (0 Replies)
Discussion started by: manas6
0 Replies
Login or Register to Ask a Question