Solved

tcsh redirection

Posted on 1999-01-27
10
773 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
The Ultimate Checklist to Optimize Your Website

Websites are getting bigger and complicated by the day. Video, images, custom fonts are all great for showcasing your product/service. But the price to pay in terms of reduced page load times and ultimately, decreased sales, can lead to some difficult decisions about what to cut.

 
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

What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

Question has a verified solution.

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

I promised to write further about my project, and here I am.  First, I needed to setup the Primary Server.  You can read how in this article: Setup FreeBSD Server with full HDD encryption (http://www.experts-exchange.com/OS/Unix/BSD/FreeBSD/A_3660-S…
FreeBSD on EC2 FreeBSD (https://www.freebsd.org) is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
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…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

728 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