0

I am creating a simple dashboard for diagnosis tool to my Data center servers. so I want to run a bash script in PHP. Please find my php coding below

<?php 
 if(isset($_POST['bashbutton'])){
    $ip="10.28.45.18";
    $st="6W8WY42";
    $output = shell_exec("sh ./Scripts/stbash.sh $ip $st");
    echo $output;
}
?>

if the script is simple bash script like below, it is working.

hostip=$1
st=$2
echo $hostip $st

But my actual bash script is attached below. If i ran this, i am not getting any output on browser.

hostip=$1
cmd='racadm getsvctag'
st=$2

out=`sshpass -p 'calvin' ssh -o StrictHostKeyChecking=no  root@$hostip "$cmd"`
echo $out

Kindly suggest me how to get the output for my actual script.

  • Does the webserver user (`apache`) have permission to execute that script? – David Oct 10 '16 at 20:08
  • [This](http://stackoverflow.com/questions/17151946/executing-bash-script-from-php-script) question may help you. – Sandeep Oct 10 '16 at 20:16
  • @David i hope, my server(mamp) having permission to execute the script. I've installed mamp on my mac and working on it. Once my dashboard is completed then only i'll move all my files to my server. kindly suggest best way to check the permission. (I'm very new to php dev.) – Arun Srinivasan Oct 10 '16 at 20:27
  • @David thanks buddy.. its working on remote server... But please help to change the same in local server(setup on my mac). – Arun Srinivasan Oct 10 '16 at 22:30

0 Answers0