<?php
$output = null;
$code = null;
$command = "/usr/bin/wmic -U administrator%pass //192.168.174.1 'select caption, name, parentprocessid, processid from win32_process'";
exec($command, $output, $code);
print_r($output);
print_r($code);
if ($code == 0) {
$round = count($output);
echo "\nThe number of elements are $round \n";
if ($round > 1) {
echo "Looping using for: \n";
for ($n = 1; $n < $round; $n++) {
echo $output[$n], "\n";
$item = split("\|", $output[$n]);
$round_item = count($item);
for ($i = 0; $i < $round_item; $i++) {
print "$item[$i] <br />";
}
};
}
}
?>
PHP7,使用 explode() 替代split()
<?php
$output = null;
$code = null;
$command = "/usr/bin/wmic -U administrator%pass, //192.168.174.1 'select caption, name, parentprocessid, processid from win32_process'";
exec($command, $output, $code);
print_r($output);
print_r($code);
if ($code == 0) {
$round = count($output);
echo "\nThe number of elements are $round \n";
if ($round > 1) {
echo "Looping using for: \n";
for ($n = 1; $n < $round; $n++) {
echo $output[$n], "\n";
$item = explode("\|", $output[$n]);
$round_item = count($item);
for ($i = 0; $i < $round_item; $i++) {
print "$item[$i] <br />";
}
};
}
}
?>