[SOLVED] pass arguments to a shell script

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
kholloi
Forum Newbie
Posts: 19
Joined: Tue Mar 30, 2004 1:08 am

pass arguments to a shell script

Post by kholloi »

Hi.

I need to execute a shell script and pass arguments to it. THe arguments are text collected in a php form and stored as variables.
So far I have done this:

Code: Select all

<?php

include('header.php');

$user = $HTTP_POST_VARS&#1111;'user'];
$pw =  $HTTP_POST_VARS&#1111;'pw'];
$pwcf =  $HTTP_POST_VARS&#1111;'pwcf'];

if ($pw == $pwcf)
&#123;
exec("./chpasswd.sh $user $pw $pwcf ");
&#125;

else
&#123;
echo("The passwords do not match, please try again");
&#125;
I have tested the shellscript and it works fine if executed manually with args, but it is not working from the php script. Am I passing the argumants in the correct manner?

Thanks
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post by pickle »

That seems to me like it might work. As it's not though, try incorporating flags into the script - ie:

Code: Select all

./chpasswd.sh -u $user -p $pw -c $pwcf
Don't ask how to use the flags in your script, 'cuz I really don't know.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
kholloi
Forum Newbie
Posts: 19
Joined: Tue Mar 30, 2004 1:08 am

Post by kholloi »

Tried that and it doesn't work.

Any other ideas guys, pleez?!?!?
redmonkey
Forum Regular
Posts: 836
Joined: Thu Dec 18, 2003 3:58 pm

Post by redmonkey »

Have you tried using the full path to the 'chpasswd.sh' script?
kholloi
Forum Newbie
Posts: 19
Joined: Tue Mar 30, 2004 1:08 am

Post by kholloi »

SOlved.

I just needed to set the uid root bit on the chpasswd.sh script for it to execute properly.
Post Reply