Hi Guys,
I read through most of the threads regarding this but I am not able to do more than connecting into a switch.
Here is the case: I need to connect to a switch via telnet and then read the commands, if password then supply the password and then supply two commands which would generate the config file which I read it into a tmp file and then I create a webpage based on that. Is there a simply way of doing this? Ok if no, I am able to connect to the switch and read the first output it generates ( a welcom message) but the second line would ask for the password which I am not able to read.
Here is the code:
$fp = fsockopen ("10.0.2.9", 23, $errno, $errstr, 60) or die("Connection failed.");
if (!$fp)
{
echo " not connected";
echo "$errstr ($errno)<br>\n";
}
else
{
flush();
$buff = fgets($fp,4096);
$line = fgets($fp,1024);
$line = fgets($fp, 1024);
echo $line;
flush();
$sec = fgets($fp, 1024);
echo $sec;
echo $sec1;
}
Can you suggest guys?
Thanks,
Raaj