0

I know that this question has been discussed before but i still can't find a solution. I'm trying to execute a Bash script from a PHP file on a (really small) website which is run using the PHP built in webserver. When running the PHP file in the terminal with

php -f test.php

it works fine and the bash script executes. However when i start the webserver and call the PHP function from the website, nothing happens. The Bash script is invoked with:

exec('/home/user/website/bash_script', $out, $return);

inside the PHP-file and i get that return = 1. On the website the PHP script that executes the bash-script is called by another PHP script through:

<input type="button" value="..." onclick="location='test.php'"/>

I first thought that it was a problem with my permissions, but i added the script-file in visudo to be able to run it as super-user without password but still no luck. I also changed the file permissions to 755. Here is test.php (which works fine when run through the terminal):

<?php
        exec ('/home/user/website/test');
?>

Also i CAN execute exec('cp bla bla2'); from the webserver so theres no problem with exec()

EDIT------------------------------------------------------------------------

The Bash script is sending a command to a different screen and it seems that this is the root of the problem. I think that this can solve my problem: Screen -X isn't working ("No screen found")

Community
  • 1
  • 1
user1621127
  • 301
  • 1
  • 3
  • 11

0 Answers0