Weedpacket,
I'm trying to implement the connection wich is a telnet conection to the equipement, and to do that I must first enter to one pc that is in the correct network, via SSH, and then send a telnet to the NMS like this:
if(!($con = ssh2_connect("172.16.3.2", 22))){ //<- this machine is in the manage network
echo "fail: unable to establish connection\n";
} else {
// try to authenticate with username root, password secretpassword
if(!ssh2_auth_password($con, "oper", "pwd")) { //<- this works well
echo "fail: unable to authenticate\n";
} else {
// allright, we're in!
echo "okay: logged in...\n";
// execute a command
if (!($stream = ssh2_exec($con, "cd /home/oper" ))) { //<- this works well too
echo "fail: unable to execute command\n";
} else {
// collect returning data from command
stream_set_blocking($stream, true);
$data = "";
while ($buf = fread($stream,4096)) {
$data .= $buf;
}
echo $data;
fclose($stream);
}
//////////////////7
//if (!($stream2 = ssh2_exec($con, "./con1.sh" ))) { //<- this is a try to do via bash, it doesnt work too
if (!($stream2 = ssh2_exec($con, "telnet 172.16.2.81 9822" ))) { //<- this does not work, the page keeps waiting for response.....
echo "fail: unable to execute command\n";
} else {
// collect returning data from command
stream_set_blocking($stream2, true);
$data = "";
while ($buf = fread($stream2,4096)) {
$data .= $buf;
}
//$buf = fread($stream2,4096);
echo $data;
fclose($stream2);
}
}
If you can help me I'll apreciate it
best regards
bernardo