On Sat, 27 Apr 2002, Dan Kenigsberg wrote:

> How can I tell, within a Perl script, whether it was executed from the command
> line, or use'd by another script?

you can only use a heuristics - use 'getppid()' to get the PID of the
parrent process. then use 'ps -o comm PID' to get its command line,
make sure to read only the second line (the first sais 'COMMAND', at least
on this redhat 6.2 system) and check if its the name of a valid user's
shell. it still does not mean it was not launched froma shell script
written in that language - so you'll want to check if this is an
interactive shell. how? no idea ;)

note: in most shells, there's some variable defined if they are
interactive shells or not, but how to read that from a perl script running
in that shell - no idea.

-- 
guy

"For world domination - press 1,
 or dial 0, and please hold, for the creator." -- nob o. dy


=================================================================
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]

Reply via email to