0

I am doing a script in php who execute a script bash(.sh).

The script works in shell but not with the interface.

Script:

<?php

echo 'test'."\n"."<BR/>";

$old_path = getcwd();
$cmd = chdir('/db/ITSA/BILLING_GENERATOR/');
echo getcwd()."\n"."<BR/>";

$output = shell_exec("./test.sh");
if($output === null){
var_dump($output2);
}else{
echo 'Pas de sortie!'.'<BR/>';
};
echo $output;
echo '<BR/>';
echo exec('whoami');

when I run php script.php on the server => output ok

when I run the script in the application have not the output with the shell_exec function.

But all other works fine.

Has someone had ever this issue. Thank you for your help.

Vincent Moulene
  • 1,193
  • 2
  • 15
  • 28
  • it's approximately the same problem but the function works when I launch the script with the bash and not with the interface. The files are at the same place when I launch the script. The output from shell : list all my files and from the interface : string(0) "" . – Vincent Moulene Oct 15 '15 at 10:07
  • and what's the content of your test.sh? – yacc Oct 15 '15 at 10:45
  • #!bin/bash sudo -user ssh user@ip ls – Vincent Moulene Oct 15 '15 at 11:08
  • did you mean bin/bash or /bin/bash? is bash present under www root? does the app run this script on client side? – yacc Oct 15 '15 at 12:05
  • /bin/bash and the file has good access. I try with only ls in the bash script and it works. May be this command did not work correctly with sudo -user ssh user@ip ls . – Vincent Moulene Oct 15 '15 at 12:20
  • 1
    you might want to know this: http://stackoverflow.com/questions/17151946/executing-bash-script-from-php-script methinkss the rights are not sufficient, you could at least add 2>&1 to your invocation so we can see the error – yacc Oct 15 '15 at 12:23

0 Answers0