in reply to STDIN schizofrenia
Correction:
[me@host bin]$ perl -we 'open STDERRIN,"+<&STDERR" or die $!; my $line + = <STDERRIN>; print STDERRIN "YAY!!! $line";' asdfasf YAY!!! asdfasf [me@host bin]$
If you are not redirecting, then STDIN, STDOUT and STDERR are really all references to the same thing, your terminal. You can see this by running (at least on linux):
as well as variations on the theme, like:ls -l /proc/self/fd/
0 = STDIN, 1 = STDOUT, and 2 = STDERR.ls -l /proc/self/fd/ < /dev/null ls -l /proc/self/fd/ | cat ls -l /proc/self/fd/ 2> /dev/null #redrect STDERR
If you want to be clever, then you can try to detect which of STDIN, STDOUT and STDERR are actually terminals, by using the -t operator. Also, you could just reach around the standard IO channels and open a direct shot to the controlling tty of the process like:
open TTY, ">/dev/tty" or die "Couldn't open /dev/tty $!";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: STDIN schizofrenia
by Abigail-II (Bishop) on Oct 13, 2003 at 09:42 UTC | |
by etcshadow (Priest) on Oct 13, 2003 at 16:05 UTC | |
by Abigail-II (Bishop) on Oct 13, 2003 at 16:22 UTC | |
by etcshadow (Priest) on Oct 13, 2003 at 19:26 UTC | |
by Abigail-II (Bishop) on Oct 13, 2003 at 22:15 UTC | |
|