//Display info upon entering the page.
$fp = fsockopen($host,$port,$errno,$errstr);
if(!$fp)
{
$results = "Error: could not open socket connection";
}
else
{
fputs ($fp, $login_info[2]."\n");//telnet password
fputs ($fp, "en\n");//enable
fputs ($fp, $login_info[3]."\n");//secret password
fputs ($fp, "terminal length 0\n");//show complete list of info without pausing
fputs ($fp, "show run\n");//show run config. command
fputs ($fp, "\r");//enter key
fgets ($fp, 1024);//ÿûÿûÿýÿý
while(true)
{
$tmpecho = fgets ($fp, 1024);
//Hide the string of terminal length 0
if(stristr($tmpecho,'terminal length 0') === FALSE )
{
$moredetails .= $tmpecho;
}
//break from the loop
if(substr($tmpecho,0,3) =='end')
{
fputs ($fp, "\r");
$moredetails .= fgets ($fp, 1024);
$moredetails .= fgets ($fp, 1024);
break;
}
}
}
fclose($fp);
2006-10-05
00:47:51
·
1 answers
·
asked by
Anonymous
in
Computers & Internet
➔ Programming & Design