LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices



Reply
 
Search this Thread
Old 04-22-2007, 02:38 PM   #1
Nuvious
Member
 
Registered: Mar 2005
Posts: 34

Rep: Reputation: 16
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`.

Last edited by Nuvious; 04-22-2007 at 03:05 PM.
 
Old 04-22-2007, 03:08 PM   #2
osor
HCL Maintainer
 
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450

Rep: Reputation: 70
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).
 
  


Reply

Tags
bash, batch, linux, output, script, stderr, stdout


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
send output of namp scan to CSV file rsmccain Linux - Networking 11 04-18-2009 09:31 PM
Send output to seperate terminals? Brain Drop Programming 3 02-25-2005 11:44 PM
How do I send output to the printer? Toker Linux - General 2 09-29-2003 11:16 AM
how to send the output to another xterm? abd_bela Programming 2 08-17-2003 01:28 PM
Need help defining Fortran 77 input/output streams using g77! Gethyn Programming 1 08-14-2003 01:42 PM


All times are GMT -5. The time now is 05:36 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration