in reply to Outputting to browser vs DOS...how can you tell?

zjunior has a pretty good idea about doing it (GATEWAY_INTERFACE will be defined if the script is run through a web-server), but what if some joker sets GATEWAY_INTERFACE to bash in his .bashrc? (stupid I know, but it's been known to happen ;), well from perlfaq8
How do I find out if I'm running interactively or not? Good question. Sometimes -t STDIN and -t STDOUT can give clues, someti +mes not. if (-t STDIN && -t STDOUT) { print "Now what? "; }
-t tells you if a filehandle is tied to a tty. Now I don't know what happens during forking and the like, but the above usually works ;)

 
______crazyinsomniac_____________________________
Of all the things I've lost, I miss my mind the most.
perl -e "$q=$_;map({chr unpack qq;H*;,$_}split(q;;,q*H*));print;$q/$q;"

  • Comment on (crazyinsomniac) Re: Outputting to browser vs DOS...how can you tell?
  • Download Code