I would like to analyse returned value of wget command.
I try those :
Your question is a little ambiguous. If you're asking "What is the exit code of the 'wget' process, that is accessible in the
$? special variable."
[~/tmp]$ wget www.google.foo --2013-11-01 08:33:52-- http://www.google.foo/ Resolving www.google.foo... failed: nodename nor servname provided, or not known. wget: unable to resolve host address ‘www.google.foo’ [~/tmp]$ echo $? 4
If you're asking for the standard output of the 'wget' command, then what you're doing is going to give you that, although you have a typo in your first line (Add a closing parentheses after "conf.txt"). The problem is that wget doesn't put anything to stdout, by default. The progress bars and messages you see when you run wget interactively are actually going to stderr, which you can see by redirecting stderr to stdout using shell redirection
[~/tmp]$ GET=`wget www.google.com 2>&1` [~/tmp]$ echo $GET --2013-11-01 08:36:23-- http://www.google.com/ Resolving www.google.com... 220.127.116.11, 18.104.22.168, 22.214.171.124, ... Connecting to www.google.com|126.96.36.199|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 18637 (18K) [text/html] Saving to: ‘index.html’ 0K .......... ........ 100% 2.72M=0.007s 2013-11-01 08:36:23 (2.72 MB/s) - ‘index.html’ saved [18637/18637]
If you're asking for the contents of the resource that wget received, then you need to instruct wget to send its output to stdout instead of a file. Depending on your flavor of wget, it's likely an option like
--output-document, and you can construct your command line as:
wget -O - <url>. By convention the single dash (
-) represents stdin and stdout in command line options, so you're telling wget to send its file to stdout.
[~/tmp]$ GET=`wget -O - www.google.com` --2013-11-01 08:37:31-- http://www.google.com/ Resolving www.google.com... 188.8.131.52, 184.108.40.206, 220.127.116.11, ... Connecting to www.google.com|18.104.22.168|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 18621 (18K) [text/html] Saving to: ‘STDOUT’ 100%[=======================================>] 18,621 98.5KB/s in 0.2s 2013-11-01 08:37:32 (98.5 KB/s) - written to stdout [18621/18621] [~/tmp]$ echo $GET <!doctype html><html itemscope="" itemtype="http://schema.org/WebPage"><head> <snip lots of content>