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.

4
  • Does the webserver user (apache) have permission to execute that script? Commented Oct 10, 2016 at 20:08
  • This question may help you. Commented Oct 10, 2016 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.) Commented Oct 10, 2016 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). Commented Oct 10, 2016 at 22:30

0

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.