in reply to Hiding/masking your username or password

The best answer is, of course, "don't pass passwords on the command line!". However...

You can change how your process appears in ps output by assigning to $0, like so:

#!/usr/bin/perl use strict; use warnings; $0 = 'renamed'; sleep 600;
Run this and you will have 10 minutes to look at ps and see that the process appears as renamed, not as whatever you saved the program as.

If you meant that your Perl code is calling other ftp/database scripts and passing username/password on the command line, then it's those other scripts that would need to do this (or something similar) to mask their command lines. The only way you'd be able to hide that information from the caller's side would be for your Perl to invoke them in interactive mode and use something like Expect to log in as if it were a human user running the (other) script.

Replies are listed 'Best First'.
Re^2: Hiding/masking your username or password
by afoken (Chancellor) on Nov 28, 2009 at 23:33 UTC

    If I remember correctly, not every OS supports assigning to argv[0] a.k.a. $0. Some OSes have limitations for assigning to it. See $0 in perlvar. Simply emptying @ARGV could also work on some OSes.

    The best way is not to have passwords at all, but use public keys instead. Second best solution is to have passwords in a file readable only for the owner. Third best solution is to have passwords in configuration files.

    Alexander

    --
    Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

        Just tried assigning to $0 and $^X on Win2000 with Strawberry Perl. Task Manager shows perl.exe in Processes whatever I try. So, it also does not work on Windows.

        Alexander

        --
        Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)