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"'

In reply to Re: Modifying command line by turo
in thread Modifying command line by horrendo

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.