Re: Can PHP works with telnet?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



In the php manual, in the fsockopen() page, in the user comments, I 
found this:

----------------------------------------------------------
Found this php class to use telnet from here:
http://cvs.adfinis.ch/cvs.php/phpStreamcast/telnet.class.php
There's no docs and a lot of it's in french though so maybe it will 
help someone to have my working code. This code is used to telnet 
into a pix and execute the "shun" command.


//-------telnet.class.php usage example---------
               $telnet = new telnet;
// Next line is for logging.  
//By default you need to create a folder called /log and give it 
//the rights your webserver is running.
               $telnet->setLog(1,"mylog");
               $telnet->set_host("myhost.myplace.com");
//You need to set the prompt to what you know its going to be,
//then call wait_prompt...which waits for what you just set
               $telnet->set_prompt("Password: ");
               $telnet->connect();
               $telnet->wait_prompt();
               $telnet->write("mypassword");
//Have to change the prompt...in my example this is the 
//prompt that a pix will change to after loggin in.
               $telnet->set_prompt("pix> ");
               $telnet->wait_prompt();
               $telnet->write("en");
               $telnet->set_prompt("Password: ");
               $telnet->wait_prompt();
               $telnet->write("enable_password");
//When you go into enable mode in a pix the prompt changes
               $telnet->set_prompt("pix# ");
               $telnet->wait_prompt();
               $telnet->write("shun " . $shun_address);
               $telnet->wait_prompt();
               $telnet->write("clear xlate");
               $telnet->wait_prompt();
               $telnet->write("write mem");
               $telnet->wait_prompt();
               $telnet->write("exit");
               $telnet->disconnect();

----------------------------------------------------------

In that same manual page, there is lots of other information and 
suggestions on making telnet connections.

Note that cURL will also allow telnet.

Geoff.


On 23 Jan 2006 at 9:56, HoWang Wang wrote:

> Hi all,
> 
> Recently I got a job to write a PHP webpage to display some infomation
> which have to obtain from telnet. Telnet is the only way to query the
> software. I have made a quick search on php.net but I can't found amy
> extension support telnet. Is there any way to do so? Or it is impossible
> with PHP but can be done with external binaries?
> Please help, thanks.
> 
> HoWang Wong
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 
> 
> !DSPAM:43d445e0116957800291649!
> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux