Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Re: Perl progname

by zentara (Archbishop)
on Aug 06, 2008 at 14:41 UTC ( [id://702648]=note: print w/replies, xml ) Need Help??

in reply to Perl progname

If you have the /proc filesystem, the most you can do is get the pid with $$, then check /proc/$pid/cmdline to get the full path to the executable.

I'm not really a human, but I play one on earth Remember How Lucky You Are

Replies are listed 'Best First'.
Re^2: Perl progname
by alexm (Chaplain) on Aug 06, 2008 at 17:10 UTC
    then check /proc/$pid/cmdline ...

    cmdline doesn't exist in Solaris /proc. Proc-ProcessTable does the trick on several platforms:

    use strict; use warnings; use Proc::ProcessTable; my $proc_table = Proc::ProcessTable->new->table; my ($process) = grep { $_->pid == $$ } @$proc_table; print $process->cmndline, "\n";
Re^2: Perl progname
by AltBlue (Chaplain) on Aug 07, 2008 at 15:21 UTC
    /proc/$$/cmdline will reflect $0's modification, e.g.:
    $ perl -le '$0="foo"; print qx "cat /proc/$$/cmdline"' foo

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://702648]
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (3)
As of 2024-07-14 09:48 GMT
Find Nodes?
    Voting Booth?

    No recent polls found

    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.