Solved

tcsh redirection

Posted on 1999-01-27
10
736 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
 
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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

A metadevice consists of one or more devices (slices). It can be expanded by adding slices. Then, it can be grown to fill a larger space while the file system is in use. However, not all UNIX file systems (UFS) can be expanded this way. The conca…
Using libpcap/Jpcap to capture and send packets on Solaris version (10/11) Library used: 1.      Libpcap (http://www.tcpdump.org) Version 1.2 2.      Jpcap(http://netresearch.ics.uci.edu/kfujii/Jpcap/doc/index.html) Version 0.6 Prerequisite: 1.      GCC …
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…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

760 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now