EDIT: I have this but still not working; I am trying to get this to check to see if that command is running. Thanks
function command_exist($cmd) {
$return = shell_exec(sprintf("which %s", escapeshellarg($cmd)));
return !empty($return);
}
if (!command_exist('rtmpdump')) {
print 'doesnt exist';
} else {
echo ' exists ';
}
On Linux/Mac
function command_exist($cmd) {
$return = shell_exec(sprintf("which %s", escapeshellarg($cmd)));
return !empty($return);
}
if (!command_exist('rtmpdump')) {
print 'doesnt exist';
} else {
shell_exec('rtmpdump');
}else {
echo ' exists ';
}
I can suggested, you could simply use:
if (`which rtmpdump`) {
shell_exec('rtmpdump');
}
<?php
function command_exist($cmd) {
$return = shell_exec(sprintf("ps -ef | grep " . escapeshellarg($cmd) . " | grep -v grep"));
return !empty($return);
}
$command = 'command here';
if (!command_exist($command)) {
print 'not running';
} else {
echo ' running ';
}
?>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.