[Omaha.pm] Detecting interactive console vs. in a script.
Daniel Linder
dan at linder.org
Thu May 18 08:19:41 PDT 2006
Has anyone seen a good way to determine if a Perl script is running on an
interactive console vs. within a shell or Perl script? I have a code
snippet that I want to print more text to a console for the user to view,
but if it is within a script I don't want to clutter its output.
On the Solaris system I'm running, I tried the "tty" command,
but both return "/dev/pts/8" when called from the command line
and within a script. The closest thing I can come to is the shell
variable $_: "-l" for interactive, and
"./<scriptname>" if run from a script.
Any other ideas?
Dan
- - - -
"Wait for that wisest of all counselors, time." -- Pericles
"I do not fear computers, I fear the lack of them." -- Isaac
Asimov
"Soon we will be able to harness the rotational energy from Orwell's
grave to solve all world energy problems." -- /. user GigsVT
(208848)
GPG fingerprint:6FFD DB94 7B96 0FD8 EADF 2EE0 B2B0 CC47 4FDE 9B68
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/pipermail/omaha-pm/attachments/20060518/b1ef0f25/attachment.html
More information about the Omaha-pm
mailing list