I'm not sure I'm using the stream_set_blocking function correctly because sometimes I get a bit of data if I run the script twice and alternative between setting stream_set_blocking to true or false. After I get 1 line sometimes, the connection seems to just drop after that.
Code: Select all
$ssh = ssh2_connect($ip, 22);
if (!ssh2_auth_password($ssh, $username, $password)) {
exit('Login Failed');
}
$vpncmd = "?";
$stream = ssh2_exec($ssh, $vpncmd) or die("error");
stream_set_blocking($stream, false);
$data = "";
while ($buf = fread($stream, 4096)) {
$data .= $buf;
}
fclose($stream);
echo $data;
Or if there's even some way I can push all my commands through Putty.exe
Thank you!