Solved

tcsh redirection

Posted on 1999-01-27
10
762 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

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 …
This tech tip describes how to install the Solaris Operating System from a tape backup that was created using the Solaris flash archive utility. I have used this procedure on the Solaris 8 and 9 OS, and it shoudl also work well on the Solaris 10 rel…
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…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

733 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