Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Changing $0 under solaris

by gnu@perl (Pilgrim)
on May 20, 2004 at 17:08 UTC ( [id://355018]=perlquestion: print w/replies, xml ) Need Help??

gnu@perl has asked for the wisdom of the Perl Monks concerning the following question:

I have the need to display different information under the 'ps -ef' output. I have tried simply setting $0='my_new_name'; but this has no effect. I looked here 83181 but it did not offer any further information

I have tried making a small program which sets $0 and then forks to see if the child would pick up the new $0, but no such luck, still just displays (/usr/bin/perl -w ./test.pl ).

This makes sense because the process table is populated with the process information before the program is evaluated, but does anyone know of a way to do this under Solaris 8?

Any Ideas?

TIA,
Chad

Replies are listed 'Best First'.
Re: Changing $0 under solaris
by Nitrox (Chaplain) on May 20, 2004 at 17:44 UTC
    You can't under Solaris. The 'ps' command reads the process table from kernel space, not user space like on Linux.

    -Nitrox

      That's what I figured (and what the evidence points to). Thanks.
Re: Changing $0 under solaris
by JSchmitz (Canon) on May 20, 2004 at 18:18 UTC
    if you want quick and dirty there are some really good alternate ps type scripts here http://www.bigadmin.com that may give you some really good ideas. You may also want to play with prstat.

    Jeffery
Re: Changing $0 under solaris
by Plankton (Vicar) on May 20, 2004 at 20:58 UTC
    Why not just call your script my_new_name then when you do a ps you'll see /usr/bin/perl -s ./my_new_name if you don't want to see the /usr/bin/perl why not just do cp /usr/bin/perl /usr/bin/somethingelse and change your shebang to run with /usr/bin/somethingelse?

    Plankton: 1% Evil, 99% Hot Gas.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (7)
As of 2024-04-23 18:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found