php shell_exec()问题[重复]

Here I get a querystring depending upon the value from the command shell_exec().

I am receiving a value the querystring but shell_exec() is not working.

I am using a webcam connected to Raspberry pi 3 so the command in shell_exec() is to turn the webcam ON an OFF.

$output=shell_exec('sudo /etc/init.d/motion start')

码:

<?php
$status=$_GET['status'];
if($status == 'on')
{
    $output=shell_exec('sudo /etc/init.d/motion start');
}
if($status == 'off')
{
    $output=shell_exec('sudo /etc/init.d/motion start');
}

我该如何解决执行问题?