LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


View Poll Results: C-Shell: Send STDOUT & STDERR to a file?
cmd >& file 1 16.67%
cmd </dev/null >& file 2 33.33%
Hahaha! I use bash or zsh! It's easy for us! 3 50.00%
Voters: 6. You may not vote on this poll

Reply
  Search this Thread
Old 09-08-2003, 02:16 PM   #1
stefanlasiewski
Member
 
Registered: Aug 2003
Location: Berkeley, California, USA
Distribution: Red Hat Enterprise Linux, Debian & Ubuntu
Posts: 92

Rep: Reputation: 16
CSH: "cmd >& file" or "cmd </dev/null >& file"


Hello Everyone,

I just started a new job where they use alot of CSH scripts, and had a question about how to send both standard output and standard error to a file.

My Unix in a nutshell book says to use this method:

cmd >& file

This is the method that I am familar with.

However, at my new work place, the 'cmd >& file' isn't used at all, and instead all of the scripts use the following method:

cmd < /dev/null >& file

cmd in this case does NOT take anything from standard input. Why would someone do this? It seems pointless.

My coworkers think I am crazy to use the first method, but nobody can explain why the second method is better (They're crazy!)

Can anyone explain the difference between these two methods?

Thanks for your help,

-= Stefan
 
Old 09-08-2003, 04:19 PM   #2
kev82
Senior Member
 
Registered: Apr 2003
Location: Lancaster, England
Distribution: Debian Etch, OS X 10.4
Posts: 1,263

Rep: Reputation: 51
both direct stdout and stderr to file, but with 'cmd >& file' if cmd (unexpectedly)asks for input then it will just sit there and wait, 'cmd < /dev/null >& file' guarantees the program does not sit there waiting for input.

if you KNOW cmd will never ever take input then use method 1 but i prefer to play it safe and plan for the future, so i would use method 2 as it will work when cmd is updated.
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Segmentation fault on toplevel = XtVaAppInitialize(&app, "Email", NULL, 0, &argc, cbranje Programming 0 02-19-2005 12:06 PM
Differences of "make" in Kdev and cmd line srisner Linux - Software 1 12-23-2004 09:44 AM
SpamAssassin Error "spamd: no response to STREAM cmd, Success" and other errors PlorkZ Linux - Software 1 11-18-2004 04:16 PM
Is there an equivalent cmd to "chkconfig (redhat)" in Debian? davidas Debian 3 04-08-2004 10:54 PM
decrypting a file using "crypt" & "rot13" JAMZM101 Solaris / OpenSolaris 1 03-07-2004 09:32 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:32 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
Open Source Consulting | Domain Registration