Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!asuvax!ncar!elroy.jpl.nasa.gov!sdd.hp.com!uakari.primate.wisc.edu!aplcen!boingo.med.jhu.edu!haven.umd.edu!uvaarpa!mmdf From: aks%anywhere@hub.ucsb.edu (Alan Stebbens) Newsgroups: comp.lang.perl Subject: Re: Redirection (STDOUT) Message-ID: <1991Jun12.172127.10044@uvaarpa.Virginia.EDU> Date: 12 Jun 91 17:21:27 GMT Sender: mmdf@uvaarpa.Virginia.EDU (Uvaarpa Mail System) Reply-To: aks%anywhere@hub.ucsb.edu Organization: The Internet Lines: 23 | Is there a way to know whether the standard output has been | redirectedinside a perl script. | | eg : perl.script > perl.script.out Just use the "-t" operator; e.g.: alias x perl -e \''printf STDERR "%sTTY\n",(-t STDOUT?"":"Not a ");'\' x TTY x > /dev/null Not a TTY x > /tmp/x Not a TTY x | cat Not a TTY x > /dev/console TTY