Re: test if stdout is connected to terminal
From: Alexis Huxley (ahuxley_at_gmx.net)
Date: 10/29/04
- Next message: Markus Wenke: "last exit status"
- Previous message: Stephane CHAZELAS: "Re: test if stdout is connected to terminal"
- In reply to: Christoph Gysin: "test if stdout is connected to terminal"
- Next in thread: Jeremiah DeWitt Weiner: "Re: test if stdout is connected to terminal"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 29 Oct 2004 13:54:23 +0200
> I need to test if stdout is connected to terminal. I know of 'tty -s'
> which does the same for stdin.
>
> Is there an equivalent to 'tty -s' for stdout?
[ -t 1 ]
Then use the return code. E.g.:
if [ -t 1 ]; then
echo "stdout is a terminal"
fi
The '1' is the file handle you want to test. 0 is stdin, 1 is stdout,
2 is stderr.
Alexis
- Next message: Markus Wenke: "last exit status"
- Previous message: Stephane CHAZELAS: "Re: test if stdout is connected to terminal"
- In reply to: Christoph Gysin: "test if stdout is connected to terminal"
- Next in thread: Jeremiah DeWitt Weiner: "Re: test if stdout is connected to terminal"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]