note 46369 added to function.fsockopen
| From: | elemental21 at hotmail dot com | Date: | Fri, 08 Oct 2004 14:23:25 +0000 |
| Subject: | note 46369 added to function.fsockopen | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-78183@lists.php.net to get a copy of this message | ||
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();
----
Manual Page -- http://www.php.net/manual/en/function.fsockopen.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+46369
Delete -- http://master.php.net/manage/user-notes.php?action=delete+46369&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+46369&report=yes
Search -- http://master.php.net/manage/user-notes.php