Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Modifying command line

by turo (Friar)
on May 12, 2008 at 00:58 UTC ( [id://686014]=note: print w/replies, xml ) Need Help??


in reply to Modifying command line

As grinder said: "there will always be a race condition between the moment the kernel launches your program and the point in time at which you'll be able to set $0 to something else.".

Anyways If you still want to hide your command line, I have a solution for you :)
It consists on saving the command line in an environment variable when the process start and then exec the same program without any arguments. Doing this, you will pass the arguments on the environment variable to the new process.
Here I show you a little program, that you can execute (e.g. myprogram -arg1 -arg2 234 -private "secret"), and try to see if you can use ps -ef to show its command line arguments.
#!/usr/bin/perl if (@ARGV) { print "Command line arguments detected ... \nHidding command l +ine ..."; my $cmdline = join " ", @ARGV; $ENV{MY_CMDLINE} = $cmdline; print "[done]\n"; exec ($0) or die "Exec: $!"; } print "\nHere is my real code baby!\n"; print "command line: $ENV{MY_CMDLINE}\n"; sleep 300;

Hope it helps.


perl -Te 'print map { chr((ord)-((10,20,2,7)[$i++])) } split //,"turo"'

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (2)
As of 2026-02-10 00:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    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.