andrius.k
andrius.k

Reputation: 819

Hide command arguments in PHP exec()

I have a script, written in C, which requires 3 parameters: host, name, password, like this:

./myscript 1.1.1.1 name mypassword

I call this using PHP exec command (need to, functionality not found in PHP).

exec('./myscript $host $name $password');

In linux, using ps command, I can see:

./myscript 1.1.1.1 name password.

How can I hide my password, that you can't see it on linux using ps?

Thank you.

Upvotes: 1

Views: 538

Answers (3)

Teun Ouwehand
Teun Ouwehand

Reputation: 89

There are example out there which does something you like: http://www.lenzg.net/archives/256-Basic-MySQL-Security-Providing-passwords-on-the-command-line.html Remember, your password is still visible for a fraction of time.

Upvotes: 1

Damien Overeem
Damien Overeem

Reputation: 4529

Since you are in a running environment. I'd temporary store your password in an environment variable (SET) and use this variable in your exec(). This way your password won't show up in ps.

Upvotes: 2

user229263
user229263

Reputation: 21

You could simply prompt the password after starting the executing of the C-script and forward the password via an pipe in PHP exec.

Upvotes: 1

Related Questions