Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a crontab that wgets a PHP page every five minutes (just to run some the PHP code), and I want to send the output to standard out. I couldn't find it in the wget manual.

I'm looking for something like:

wget -o stdout http://whatever.com/page.php > /dev/null

Anyone know?

share|improve this question

migrated from stackoverflow.com Aug 10 '11 at 6:09

This question came from our site for professional and enthusiast programmers.

2  
Mistitled, should be "How do you redirect wget to null?". – BobStein-VisiBone Dec 30 '14 at 13:47
1  
@BobStein-VisiBone I think it is titled correctly. I wanted the thing that is wget-ed to go to a stdout, and the normal stdout to go to null (i.e. ignore what it usually prints, and instead print the response body). – Sean Adkinson Dec 31 '14 at 1:24
    
Oh! I stand corrected. I have started using wget http://example.com/page.php -qO- (That's a capital Oh.) That standard-outputs ONLY the response body. Is that what you wanted? – BobStein-VisiBone Dec 31 '14 at 4:32
up vote 54 down vote accepted

wget -O - http://whatever.com/page.php > /dev/null

or, if you want to redirect standard error output also:

wget -O - http://whatever.com/page.php > /dev/null 2>&1

or, for codegolf :-)

wget -O-

share|improve this answer
1  
You may want to add -nv to avoid the progress indicator overwriting the output. – Tor Klingberg Nov 10 '15 at 15:25
wget -qO /dev/null http://whatever.com/page.php
  • -q to make it quiet
  • -O /dev/null to ignore the page contents
share|improve this answer

You can also try:

wget -q -O - http://whatever.com/page.php > /dev/null 

the -q will make it "quiet"

Or have the file go to some temp html page that you don't mind having. whatever.com/tempFile.html

share|improve this answer
wget -O /dev/null http://example.com/
share|improve this answer
    
It works on my mac with wget 1.12. – Simon Aug 9 '11 at 22:29
    
Could you provide some explanation about what your code does? – Tom Wijsman Nov 5 '11 at 1:14

A simpler version

wget -qO- http://example.com

equivalent to

wget -q -O - http://example.com

where

  • -q turns off the output of log, including error information
  • -O -, equivlalent to -O /dev/stdout, means dump the web page to a file named /dev/stdout.
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .