Skip to main content
Stack Overflow
  1. About
  2. For Teams

Return to Revisions

2 of 4
added 135 characters in body
jasinth premkumar
  • 1.4k
  • 1
  • 13
  • 23

shell_exec — Execute command via shell and return the complete output as a string . reference

<?php
 if(isset($_POST['switch'])){
 $c=escapeshellcmd("sudo python /home/pi/Desktop/test.py");
 $res=shell_exec($c);
 echo $res; // returns result to display
 }
?>

in your script,output is not printed that may seem to not working

 <?php
 if(isset($_POST['switch'])){
 $s=exec("sudo python /home/pi/Desktop/test.py");
 echo "$s"; 
}
 ?>
jasinth premkumar
  • 1.4k
  • 1
  • 13
  • 23

AltStyle によって変換されたページ (->オリジナル) /