note 33411 modified in function.fsockopen by danbrown
| From: | danbrown@php.net | Date: | Sun, 20 Jul 2008 19:54:23 +0000 |
| Subject: | note 33411 modified in function.fsockopen by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-142323@lists.php.net to get a copy of this message | ||
To make a telnet connection with a Cisco router:
<?php
$cfgServer = "192.168.0.10"; //IP of your router
$cfgPort = 23; //port, 22 if SSH
$cfgTimeOut = 10;
$usenet = fsockopen($cfgServer, $cfgPort, &$errno, &$errstr, $cfgTimeOut);
if(!$usenet)
{
echo "Connexion failed\n";
exit();
}
else
{
echo "Connected\n<BR>";
fputs ($usenet, "toto\r\n");
fputs ($usenet, "en\r\n");
fputs ($usenet, "tutu\r\n");
fputs ($usenet, "exit\r\n");
while (!feof($usenet))
{
echo ". ".fgets($usenet, 128)."<BR>\n";
}
}
?>
Then you will have:
Connected
. ��������
.
. User Access Verification
.
. Password:
. testXB>en
. Password:
. testXB#exit
.
--was--
To make a telnet connection with a Cisco router:
$cfgServer = "192.168.0.10"; //IP of your router
$cfgPort = 23; //port, 22 if SSH
$cfgTimeOut = 10;
$usenet = fsockopen($cfgServer, $cfgPort, &$errno, &$errstr, $cfgTimeOut);
if(!$usenet)
{
echo "Connexion failed\n";
exit();
}
else
{
echo "Connected\n<BR>";
fputs ($usenet, "toto\r\n");
fputs ($usenet, "en\r\n");
fputs ($usenet, "tutu\r\n");
fputs ($usenet, "exit\r\n");
while (!feof($usenet))
{
echo ". ".fgets($usenet, 128)."<BR>\n";
}
}
Then you will have:
Connected
. ÿûÿûÿýÿý
.
. User Access Verification
.
. Password:
. testXB>en
. Password:
. testXB#exit
.
http://php.net/manual/en/function.fsockopen.php