I have a script that uses subprocesses to fetch HTML:
misha@misha-K42Jr:~/git/domain_classifier$ python webkit_retrieve.py error-cut.txt html/error -N 5
http://kurabo.co.jp HostNotFoundError
http://monarch.com HostNotFoundError
http://nssmgmt.com HostNotFoundError
http://sbcglobal.net HostNotFoundError
http://dynamixcorp.com SslHandshakeFailedError
http://groupe-synox.com RemoteHostClosedError
QFont::setPixelSize: Pixel size <= 0 (0)
http://www.cnn.com NoError
http://pacbell.net TimeoutError
If I run the same script, but redirect output to a file, I get nothing in the output:
misha@misha-K42Jr:~/git/domain_classifier$ python webkit_retrieve.py error-cut.txt html/error -N 5 > stdout.txt
QFont::setPixelSize: Pixel size <= 0 (0)
misha@misha-K42Jr:~/git/domain_classifier$ cat stdout.txt
misha@misha-K42Jr:~/git/domain_classifier$
Why is the output empty? Should it not contain the same things that were printed to stdout in the first case?
The question is not about merge stdout and stderr but why redirected stdout produce an empty file
use &>
for redirection, this should redirect stdout
and stderr
to designated file
You have sent stdout to the file, but your program is reporting errors which go to stderr. To setup redirection of stderr, use 2>
syntax.
This link might help: http://www.tldp.org/LDP/abs/html/io-redirection.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With