The following php script works for simple linux commands, like ps -ef , but when i use ./dstat -t -a , it seems to hang and i dont get the prompt back on my local machine. Kep in mind that all commands are executed over ssh on a remote host:
<?php
$target = time() . '_' . 'txt';
if($ssh = ssh2_connect('10.1.0.174', 22)) {
if(ssh2_auth_password($ssh, 'root', 'kmoon77')) {
//$stream = ssh2_exec($ssh, 'whoami');
$sCommand = 'dstat -a';
//$sCommand = 'ps -ef';
$stream = ssh2_exec($ssh, $sCommand);
//$stream = ssh2_exec($ssh, 'pwd');
stream_set_blocking($stream, true);
$data = '';
while($buffer = fread($stream, 4096)) {
$data .= $buffer;
}
//fclose($stream);
echo $data; // user
}
}
?>