LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   How use shell_exec funtion in php 5.2.5 over linux (https://www.linuxquestions.org/questions/programming-9/how-use-shell_exec-funtion-in-php-5-2-5-over-linux-757328/)

pinwilinux 09-23-2009 02:26 PM

How use shell_exec funtion in php 5.2.5 over linux
 
Hi I am new in php and try to use shell_exec function but don't work properly, the problem is donīt show any message error. my script is

$cli = "/public_html/newcli";
$dat = "-P/public_html/";
$execute = $cli." aut ".$tarjeta." ".$mesexpira." ".$anexpira." ".$monto2." ".$dat;
$cliresult = shell_exec($execute);

in variable &cli search a newcli file
in variable $dat search a cgi.dat file
in variable $clireult sow result of process

but donīt show anything, I think if can not find the folder should be display an error, but does not give me any error and not run the process

please help me.

Thanks.

nc3b 09-23-2009 02:37 PM

Welcome to LQ!

Try echo'ing $execute before shell_exec.. Also try running a simpler command (ls comes to mind..) at first

www.php.net
Quote:

Note: This function is disabled when PHP is running in safe mode
Don't want to be a nag, but you do realize, it's _quite_ unsafe.

HTH, Cheers

pinwilinux 09-23-2009 04:25 PM

Thanks for help
 
Tanks but not understand your response, sorry I am very very new in php, this is my first experience in php, if you could expand a little more your response, I appreciate.

nc3b 09-24-2009 12:51 AM

Hello, sorry for answering so late. Here's what you should do:
1. Make sure this function is available to you:


PHP Code:

<?
    $answer 
shell_exec('ls');
    echo(
$answer);
?>


2. Then, if that works:

PHP Code:

<?
    $cli 
"/public_html/newcli";
    
$dat "-P/public_html/";
    
$execute $cli." aut ".$tarjeta." ".$mesexpira." ".$anexpira." ".$monto2." ".$dat;
    
# $cliresult = shell_exec($execute);
    
echo($execute);
?>


You will see the command as it would be run by shell_exec. Try running it by hand and see what happens. Cheers :)


All times are GMT -5. The time now is 12:54 AM.