0

Hi i m trying to execute a bash file which contains a command to run a script file. I had been trying all possible methods but nothing seem to work. I want to run the file and display the result on the web page.

the bash file contains arguments to execute the script. i tried with

system(./bashfile path);
shell_exec(./file path);

if(isset($_POST['submit'])) {


    $output = shell_exec('./Users/file.sh ');
    echo "<pre>$output</pre>";

but nothing happens. what other ways i could execute the .sh file, help appriciated

1
  • Use absolute path, not relative (i.e. starting with ./) Commented Dec 11, 2013 at 8:03

1 Answer 1

2

system(),exec(),shell_exec(),... functions might be disabled because of security. Also on the phpinfo page of shell_exec you can find:

This function can return NULL both when an error occurs or the program produces no output. It is not possible to detect execution failures using this function. exec() should be used when access to the program exit code is required.

try:

$command = './Users/file.sh';
$output = '';
exec ( $command, $output, $return_var );
var_dump($output);
var_dump($return_var);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.