Hi,
I wish to check the return value for wget $url
.
However, some urls are designed to take 45 minutes or more to return.
All i need to check if the URL can be reached or not using wget.
How can i get wget
to return the value in a few seconds ?
why don't you ping it if you want to check the reachability?
--ahamed
Becoz, I need to check the complete URL not just the hostname portnumber
Use the --spider
option of wget
--ahamed
Does not help. Here is the output as it hangs as seen below.
$ wget --spider http://helloz.net:2400/enu/start.swe?Source=SecureWebService
Spider mode enabled. Check if remote file exists.
--2014-02-24 12:00:30-- http://helloz.net:2400/enu/start.swe?Source=SecureWebService
Resolving helloz.net... 235.79.60.30
Connecting to helloz.net|235.79.60.30|:2400... failed: Connection timed out.
Retrying.
--2014-02-24 12:02:44-- (try: 2) http://helloz.net:2400/enu/start.swe?Source=SecureWebService
Connecting to helloz.net|235.79.60.30|:2400...
You see the connection timeout, thats a problem. It is not able to connect in the first place. Try increasing the timeout.
Normally how long does it take to start transferring the file once you issue the command?
--ahamed
Try : specify timeout variable in seconds
$ wget -q -t 1 --timeout=200 http://url.com
$ echo $?
1 Like
The default is to retry 20 times. You can specify different tries.
-t number
--tries=number
GNU Wget 1.13.4 Manual