Posted: Tue Oct 18, 2005 6:56 pm Post subject: router config with php
Hi! I'm currently doing on a pj which need to make amendment to the source code written by others. It is some sort of web-based configuration of Router/Switch using php programming. The source code which was done previously had problem showing full information of router/switch.
Using HypterTerminal
E.g: show run configuration information.
It has a limited maximum no. of lines to display the informations, (30 lines). Once it reached the line tat say "more", you will have to press either spacebar to display the remaining information or enter to display line by line.
Web-Based Configuration
After loggin into the router config, u will be direct to it general page which display the show run config information. After the "more", we found the first 3 lines missing. Provided below is the source code tat program tis part. I have stated the comments tat I don't understand. Do hope there's ppl willin to help me solve this problem.
Code:
$fp = fsockopen ($host, $port, $errno, $errstr);
if (!$fp)
{
$results = "Error: could not open socket connection";
}
else
{
fputs ($fp, $login_info[2]."\n");
fputs ($fp, "en\n");
fputs ($fp, $login_info[3]."\n");
fputs ($fp, "show run\n");
fputs ($fp, "\r");
//Require more explanation on tis portion till the end. Solve the problems.
$i = 0;
for ($i=0; $i<=30; $i++)
{
//how do tis function? substr() meaning...
if (substr($tmpecho, 0, 9) != " --More--")
$moredetails .= fgets ($fp, 1024);
}
fputs ($fp, "\r");
//How does tis looping and checking functions.
while (true) {
fputs ($fp, " ");
$tmpecho = fgets ($fp, 1024);
if (substr($tmpecho, 0, 9) != " --More--"){
$moredetails .= $tmpecho;
}
if (substr($tmpecho, 0, 3) == 'end') {
break;
}
}
}
fclose($fp);
I'm appreciate if u could spend some time with me. Thanks ppl.
I supose you are playing with Cisco Routers , if so I can give you a trick. When you are on enable you can use the command "terminal length 0" which makes that every time you issue a command the Cisco Dev will output all results without asking for More and More.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum