Page 1 of 1
Executing linux commands from php with input
Posted: Mon Mar 15, 2004 2:58 pm
by quo
Exactly what the subject says. I need to execute some commands that need user input. Let's say, I need to execute 'passwd' from php and how can I do that in php and change someone's pwd?
Tnx
Posted: Mon Mar 15, 2004 3:43 pm
by penguinboy
Posted: Tue Mar 16, 2004 5:53 am
by quo
here is the example:
i want to execute su command.
and i write in php code
<pre>
<?php system('su'); ?>
</pre>
and i get output password: or root password:
and what now
how can i send the password?

Posted: Tue Mar 16, 2004 8:29 pm
by timvw
man su? :p
Anyway, exec("su - foo"); exec("bar"); is not the way to run bar as user foo.
Perhaps you should have a look at cgi-wrap stuf

(I thought i recently had seen a php-wrap module for apache, but i don't seem to find a link to the project)
Posted: Wed Mar 17, 2004 5:49 am
by alucard
If you need interactivity with script, you will be using the expect unix command.
http://www.raycosoft.com/rayco/support/ ... tutor.html
In a few words, you will be creating a bash scrint that runs su, checks out when the word password appears, then it will automagically feed your password. From php you will be executing the bash script.
Posted: Wed Mar 17, 2004 4:33 pm
by Pyrite
quo may I ask what you are wanting to do with all this? Just curious.