What's new
Your Hosting Talk

Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

How to run a Bash script via PHP and match the output?

Hello guys,

Is anyone here from Php background, I am here for some solution, can you please let me know, How to run a Bash script via PHP and match the output?
 
You do it with exec ie:

$exec = exec('/bin/sh /bin/scripts/myscript.sh ' , $output, $return);

and you can see the output with:

var_dump($output);
 
Hello,

Php has a function called shell_exec which takes a file path as a parameter. You could write the bash command in a file and call the shell_exec method with the path of that file
 

Users who are viewing this thread

Back
Top