1

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.

1
  • Do you need other outputs from ./myscript or can it be run by another process ie. you need know data returned from it if so add & should do the trick like so exec(./myscript $host $name $password &') this will basically spawn another process to handle exec ... (similar to a thread in this situation) Commented Aug 6, 2013 at 13:01

3 Answers 3

2

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.

Sign up to request clarification or add additional context in comments.

2 Comments

A little example pls. P.S. name and password are changing (they are for users authentication)
Since you already accepted an answer i doubt this is still userfull, but for setting an environment variable: php.net/manual/en/function.putenv.php
1

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.

Comments

1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.