Starter of a script
Hello every body, How to know what task have run a perl script ? I mean is possible to get within the code which process Id have start the script. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Starter of a script
It is posible on unix like system ( must be possible on others too But I dont know ) On my machine which happens to be linux I do $Parent_id = `cat /proc/$$/status |grep PPid |awk '{print \$2}'` chomp $Parent_id If you want the process name too you will get it from /proc/$Parent_id/stat But be warned that this process will work only if the parent is still running else It will show init Cedric Gross wrote: Hello every body, How to know what task have run a perl script ? I mean is possible to get within the code which process Id have start the script. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Starter of a script
It is posible on unix like system ( must be possible on others too But I dont know ) On my machine which happens to be linux I do $Parent_id = `cat /proc/$$/status |grep PPid |awk '{print \$2}'` chomp $Parent_id If you want the process name too you will get it from /proc/$Parent_id/stat But be warned that this process will work only if the parent is still running else It will show init Cedric Gross wrote: Hello every body, How to know what task have run a perl script ? I mean is possible to get within the code which process Id have start the script. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Starter of a script
It is posible on unix like system ( must be possible on others too But I dont know ) On my machine which happens to be linux I do $Parent_id = `cat /proc/$$/status |grep PPid |awk '{print \$2}'` chomp $Parent_id If you want the process name too you will get it from /proc/$Parent_id/stat But be warned that this process will work only if the parent is still running else It will show init Cedric Gross wrote: Hello every body, How to know what task have run a perl script ? I mean is possible to get within the code which process Id have start the script. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Starter of a script
Cedric Gross wrote: > > Hello every body, Hello, > How to know what task have run a perl script ? > I mean is possible to get within the code which process Id have start the > script. perldoc -f getppid John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Starter of a script
On Thursday 21 November 2002 03:21 am, cedric gross wrote: > Hello every body, > > How to know what task have run a perl script ? > I mean is possible to get within the code which process Id have start the > script. If you're running Linux or Unix, perl holds your environment variables in a hash; %ENV. Your process id number is $ENV{PID}. HTH, Chris Browning [EMAIL PROTECTED] "Hah!!" -- James Brown -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Starter of a script
On Nov 22, Chris Browning said: >On Thursday 21 November 2002 03:21 am, cedric gross wrote: >> Hello every body, >> >> How to know what task have run a perl script ? >> I mean is possible to get within the code which process Id have start the >> script. > >If you're running Linux or Unix, perl holds your environment variables in a >hash; %ENV. Your process id number is $ENV{PID}. You can just use the $$ variable too. -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ what does y/// stand for? why, yansliterate of course. [ I'm looking for programming work. If you like my work, let me know. ] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Starter of a script
Jeff japhy Pinyan said: > On Nov 22, Chris Browning said: > >>On Thursday 21 November 2002 03:21 am, cedric gross wrote: >>> Hello every body, >>> >>> How to know what task have run a perl script ? >>> I mean is possible to get within the code which process Id have start >>> the script. >> >>If you're running Linux or Unix, perl holds your environment variables >> in a hash; %ENV. Your process id number is $ENV{PID}. > > You can just use the $$ variable too. Good answers to the wrong quiestion ;-) I think the requirement is to find the process id of the parent process. $ENV{PPID} might give you that (it does on Solaris 8 which doesn't have $PID) or you might be able to find out by calling C. perl -V:d_getppid will tell you whether your perl supports this call. perldoc -f getppid for what it's worth ;-) [ Didn't someone already answer this? Oh for a decent threaded webmail thingy. ] -- Paul Johnson - [EMAIL PROTECTED] http://www.pjcj.net -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]