Executing linux commands from php with input

Whether you are using Linux on the desktop or as a server, it's still good that you're using Linux. Linux related questions go here.

Moderator: General Moderators

Post Reply
quo
Forum Newbie
Posts: 2
Joined: Mon Mar 15, 2004 2:58 pm

Executing linux commands from php with input

Post 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
penguinboy
Forum Contributor
Posts: 171
Joined: Thu Nov 07, 2002 11:25 am

Post by penguinboy »

quo
Forum Newbie
Posts: 2
Joined: Mon Mar 15, 2004 2:58 pm

Post 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? :(
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post 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)
alucard
Forum Newbie
Posts: 3
Joined: Wed Mar 17, 2004 5:49 am

Post 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.
User avatar
Pyrite
Forum Regular
Posts: 769
Joined: Tue Sep 23, 2003 11:07 pm
Location: The Republic of Texas
Contact:

Post by Pyrite »

quo may I ask what you are wanting to do with all this? Just curious.
Post Reply