How Do You Get a PHP Script to Invoke a Bash Command?

Problem scenario
You are trying to get a PHP file to invoke a bash script. When you run it from the command line with "php foobar.php" you just see the content of the PHP file. What do you do to get PHP to invoke a bash script?

Make sure you have the correct header and closing symbols. Here is the content of foobar.php:

exec('bash /var/www/html/');

To run it, do this: php foobar.php

Leave a comment

Your email address will not be published. Required fields are marked *