I am trying to define inside a Perl script on Linux, regardless of whether it works in the terminal.
That is, I need a code that:
- returns true on simple command line startup
- also returns true on startup
./myscript.pl | less ./myscript.pl | less or even ./myscript.pl </dev/null >/dev/null 2>/dev/null - returns false when run in cron job or as a cgi script
Especially because of the second bullet, I can't use -t STDOUT and options, as well as IO :: Interactive is useless.
Information appears to be available. If I started ps , an entry like pts/2 will appear in the TTY column, even when I run ./myscript.pl </dev/null >/dev/null 2>/dev/null and ? when working as a cron job or CGI script.
Is there an elegant way to define this in a Perl script? I would prefer not to parse the ps output.
mscha source share