LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Send ALL output streams to file? (https://www.linuxquestions.org/questions/linux-general-1/send-all-output-streams-to-file-548099/)

Nuvious 04-22-2007 01:38 PM

Send ALL output streams to file?
 
Hey,
I'm writing a batch file script to get web comics for me. However, wget sends output to streams 1 and 2 and I want both to go to a file.


!#/bin/bash

while true;
do
wget -nc thiswebcomic.com/current_comic.php >> wget.out
wget -nc morecomics.com/current_comic.php >> wget.out
...
wget -nc lastcomic.com/current_comic.php >> wget.out
done

Because of the networking, wget sends output to both stdout and stderr even if there isn't an error in the download. Is there some way to pipe both stdout and stderr to the same file so there is no console output when running this script?

PROBLEM SOLVED
I didn't necessarily want to read the output, so I simply put it in ` quotes. EX: `wget -nc randompage.com` And that did it. Also if I wanted to pipe stderr and stdout to the same output file, I found out I could just do `wget -nc randompage.com 2>> file.txt 1>> file.txt`.

osor 04-22-2007 02:08 PM

Quote:

Originally Posted by Nuvious
PROBLEM SOLVED
I didn't necessarily want to read the output, so I simply put it in ` quotes. EX: `wget -nc randompage.com` And that did it. Also if I wanted to pipe stderr and stdout to the same output file, I found out I could just do `wget -nc randompage.com 2>> file.txt 1>> file.txt`.

You could also do “command >> file.txt 2>&1” (send output destined for file descriptor 2 to file descriptor 1).


All times are GMT -5. The time now is 03:29 AM.