Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!convex!usenet From: tchrist@convex.COM (Tom Christiansen) Newsgroups: comp.lang.perl Subject: Re: re(REDIRECTION) Message-ID: <1991Jun16.041610.4736@convex.com> Date: 16 Jun 91 04:16:10 GMT References: <8382@awdprime.UUCP> Sender: usenet@convex.com (news access account) Reply-To: tchrist@convex.COM (Tom Christiansen) Organization: CONVEX Software Development, Richardson, TX Lines: 19 Nntp-Posting-Host: concave.convex.com From the keyboard of root@hotwheel.austin.ibm.com (/50000): :>Hi guys, :> I have a question with respect to redirection. :> :> Is there a way to know whether the standard output has been redirectedinside a perl script. :> :>eg : perl.script > perl.script.out :> :>here as you see the standard output is being redirected to perl.script.out : : I just found out that there is a C library routine - isatty :to know whether the STDOUT has been redirected to a file. : So I guess I have to write a small C function to use it in my perl script. : If you guys out there have any other ideas, I really would appreciate it. Just use the -t operator on the STDOUT handle. Even if that weren't available, you could just do a TIOCGETP ioctl on it instead. --tom