Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Perl progname

by zentara (Cardinal)
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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2025-11-08 02:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your view on AI coding assistants?





    Results (65 votes). Check out past polls.

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.