Page 1 of 1

pass arguments to a shell script

Posted: Fri Aug 20, 2004 8:51 am
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

Posted: Fri Aug 20, 2004 9:16 am
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.

Posted: Sat Aug 21, 2004 6:26 am
by kholloi
Tried that and it doesn't work.

Any other ideas guys, pleez?!?!?

Posted: Sat Aug 21, 2004 6:35 am
by redmonkey
Have you tried using the full path to the 'chpasswd.sh' script?

Posted: Mon Aug 23, 2004 3:16 am
by kholloi
SOlved.

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