Solved

tcsh redirection

Posted on 1999-01-27
10
753 Views
Last Modified: 2011-09-20
How can I redirect stderr to /dev/null, and keep stdout going to stdout? Something like:
(foo > stdout) >& /dev/null
But that doesn't work, obviously. Easy in bash, but I can't figure it out in tcsh.
thanks,
trails
0
Comment
Question by:trails
  • 4
  • 4
  • 2
10 Comments
 
LVL 3

Expert Comment

by:mliberi
ID: 2009423
"bash -c 'foo 2>/dev/null'" isn't acceptable?
0
 

Author Comment

by:trails
ID: 2009424
Yeah, it's okay, I guess I would just like to know if it's possible in tcsh. But I don't think it is. You can redirect to /dev/tty, but that's a hack that doesn't work very well at all.
Thanks for the comment,
trails
0
 
LVL 3

Expert Comment

by:mliberi
ID: 2009425
proposing the same as an answer:

"bash -c 'foo 2>/dev/null'"
0
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
LVL 51

Expert Comment

by:ahoffmann
ID: 2009426
it can be done in tcsh too, without using bash
0
 

Author Comment

by:trails
ID: 2009427
I'm sorry, I'm going to have to reject that answer on principle. First: I already knew how to do it in bash, as I stated in my original question. Second: someone says it's possible, so if there's an answer, that deserves the points.
trails
0
 
LVL 51

Accepted Solution

by:
ahoffmann earned 50 total points
ID: 2009428
(your_command >`tty`)>&/dev/null

This is the only case where redirecting in csh/tcsh is more cumbersome than in other shells, but it's well documented too.
Keep in mind that csh/tcsh was made for interactive usage, where an errorenous command's output usually is useless, while the error message is important (and not vice versa as you prefer in your situation ;-)
0
 
LVL 3

Expert Comment

by:mliberi
ID: 2009429
the proposed answer redirects output to /dev/tty, so stdout doesn't keep going to stdout (as the question stated).
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 2009430
mliberi, what do think is the difference between stdout and /dev/tty (in this special case)?
BTW, it does not redirect to /dev/tty, more correctly to the shells tty; see man tty
0
 
LVL 3

Expert Comment

by:mliberi
ID: 2009431
There is a big difference between tty and stdout.

Suppose your command has been placed in a script, let's say 'xxx'

By calling the script with the syntax "xxx >myfile" I would expect that the output of the script to be written to "myfile". With the command you gave the output would be placed on the screen.

from "tty" man page:
>  tty Command

>  Purpose

>  Writes to standard output the full path name of your terminal.

Do you still think that stdout and `tty` to be the same thing?
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 2009432
well I agree for the special case: script-file :-)
(you remember my comment: this special case?)

If you would do in a csh script, you would probably  to do it like:

   (your_command > tmp_file)>&/dev/null
  cat tmp_file

As I, said in my answer: redirecting stdout without stderr is not implemented in
csh/tcsh.
So trails no knows how to do it interactiv and in a script ;-)
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello fellow BSD lovers, I've created a patch process for patching openjdk6 for BSD (FreeBSD specifically), although I tried to keep all BSD versions in mind when creating my patch. Welcome to OpenJDK6 on BSD First let me start with a little …
I have been running these systems for a few years now and I am just very happy with them.   I just wanted to share the manual that I have created for upgrades and other things.  Oooh yes! FreeBSD makes me happy (as a server), no maintenance and I al…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question