RE: [PHP] Telnet and PHP
Jon, Looked like a nice solution, but couldn't get the code to work. Kept going into an endless loop or wait state somewhere. still forced to use rexec. Warren Vail -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Saturday, June 30, 2001 11:06 AM To: Warren Vail Cc: [EMAIL PROTECTED] Subject: Re: [PHP] Telnet and PHP Instead of performing a send for each stroke, the user code type in a whole string in a text box, and then submit that string. I have found this code at http://www.phpbuilder.com/mail/php-general/2001051/1479.php: ? error_reporting(-1); class Telnet { /* (c) [EMAIL PROTECTED] */ var $sock = NULL; function telnet($host,$port) { $this-sock = fsockopen($host,$port); socket_set_timeout($this-sock,2,0); } function close() { if ($this-sock) fclose($this-sock); $this-sock = NULL; } function write($buffer) { $buffer = str_replace(chr(255),chr(255).chr(255),$buffer); fwrite($this-sock,$buffer); } function getc() { return fgetc($this-sock); } function read_till($what) { $buf = ''; while (1) { $IAC = chr(255); $DONT = chr(254); $DO = chr(253); $WONT = chr(252); $WILL = chr(251); $theNULL = chr(0); $c = $this-getc(); if ($c === false) return $buf; if ($c == $theNULL) { continue; } if ($c == \021) { continue; } if ($c != $IAC) { $buf .= $c; if ($what == (substr($buf,strlen($buf)-strlen($what { return $buf; } else { continue; } } $c = $this-getc(); if ($c == $IAC) { $buf .= $c; } else if (($c == $DO) || ($c == $DONT)) { $opt = $this-getc(); // echo we wont .ord($opt).\n; fwrite($this-sock,$IAC.$WONT.$opt); } elseif (($c == $WILL) || ($c == $WONT)) { $opt = $this-getc(); // echo we dont .ord($opt).\n; fwrite($this-sock,$IAC.$DONT.$opt); } else { // echo where are we? c=.ord($c).\n; } } } } $tn = new telnet(192.168.255.100,23); echo $tn-read_till(ogin: ); $tn-write(admin\r\n); echo $tn-read_till(word: ); $tn-write(thieso\r\n); echo $tn-read_till(: ); $tn-write(ps\r\n); echo $tn-read_till(: ); echo $tn-close(); ? - Original Message - From: Warren Vail [EMAIL PROTECTED] To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Saturday, June 30, 2001 2:01 PM Subject: RE: [PHP] Telnet and PHP By active user input, I would assume that you mean every time the user makes a keystroke, the keystroke is sent to the host machine. This is not a characteristic of html which only sends information to the host machine when some form of submit is clicked. The advantage of the applet for this sort of thing is it runs on the browser client, and has the capability of sending every keystroke directly to the host, bypassing the server side. On the server side, once the (PHP) application is done sending the requested files to the web browser for one user, it moves on to handling the requests for other users. Can you imagine the load on a server if it had to reload your application every time, your user pressed a key. You never really made it clear where you expected this client to run, although PHP, at this point, can only run on the server. Now if you are looking for something that your PHP code could use to 1. signon to a host somewhere, 2. execute some commands, 3. capture and process the results and 4. disconnect before completing a single page to a web browser client (it will probably never do active user input, because of the nature of PHP and the web server), then I would suggest you consider rexec, rcp, rsh or if what you want is in a file on the host machine, you could use the ftp functions. These are not telnet, and do require special deamons running on the host machine, but may do the trick. I have been looking for your telnet client for a long time as well, and if you find one, please remember
RE: [PHP] Telnet and PHP
By active user input, I would assume that you mean every time the user makes a keystroke, the keystroke is sent to the host machine. This is not a characteristic of html which only sends information to the host machine when some form of submit is clicked. The advantage of the applet for this sort of thing is it runs on the browser client, and has the capability of sending every keystroke directly to the host, bypassing the server side. On the server side, once the (PHP) application is done sending the requested files to the web browser for one user, it moves on to handling the requests for other users. Can you imagine the load on a server if it had to reload your application every time, your user pressed a key. You never really made it clear where you expected this client to run, although PHP, at this point, can only run on the server. Now if you are looking for something that your PHP code could use to 1. signon to a host somewhere, 2. execute some commands, 3. capture and process the results and 4. disconnect before completing a single page to a web browser client (it will probably never do active user input, because of the nature of PHP and the web server), then I would suggest you consider rexec, rcp, rsh or if what you want is in a file on the host machine, you could use the ftp functions. These are not telnet, and do require special deamons running on the host machine, but may do the trick. I have been looking for your telnet client for a long time as well, and if you find one, please remember to post it here, but I would suspect that one of the problems in doing a telnet client in php is that the telnet client needs to be multi-threaded. Perhaps someone will someday take open source like Dave's Telnet and fashion an extension to PHP. Til then, try the options above, Warren Vail -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Saturday, June 30, 2001 10:36 AM To: [EMAIL PROTECTED] Subject: [PHP] Telnet and PHP I was doing some research on creating a webbased telnet client and I am unsatisfied with Java applets. I would like to create a server side telnet client, so the user side is only required to have a working web browser that supports HTML. Thus, I turned to PHP. I found one example, but it does not allow for active user input. While I will sit down this evening and work with the code, I was wondering if anyone had/knew of a good example of a PHP telnet client. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Telnet and PHP
Instead of performing a send for each stroke, the user code type in a whole string in a text box, and then submit that string. I have found this code at http://www.phpbuilder.com/mail/php-general/2001051/1479.php: ? error_reporting(-1); class Telnet { /* (c) [EMAIL PROTECTED] */ var $sock = NULL; function telnet($host,$port) { $this-sock = fsockopen($host,$port); socket_set_timeout($this-sock,2,0); } function close() { if ($this-sock) fclose($this-sock); $this-sock = NULL; } function write($buffer) { $buffer = str_replace(chr(255),chr(255).chr(255),$buffer); fwrite($this-sock,$buffer); } function getc() { return fgetc($this-sock); } function read_till($what) { $buf = ''; while (1) { $IAC = chr(255); $DONT = chr(254); $DO = chr(253); $WONT = chr(252); $WILL = chr(251); $theNULL = chr(0); $c = $this-getc(); if ($c === false) return $buf; if ($c == $theNULL) { continue; } if ($c == \021) { continue; } if ($c != $IAC) { $buf .= $c; if ($what == (substr($buf,strlen($buf)-strlen($what { return $buf; } else { continue; } } $c = $this-getc(); if ($c == $IAC) { $buf .= $c; } else if (($c == $DO) || ($c == $DONT)) { $opt = $this-getc(); // echo we wont .ord($opt).\n; fwrite($this-sock,$IAC.$WONT.$opt); } elseif (($c == $WILL) || ($c == $WONT)) { $opt = $this-getc(); // echo we dont .ord($opt).\n; fwrite($this-sock,$IAC.$DONT.$opt); } else { // echo where are we? c=.ord($c).\n; } } } } $tn = new telnet(192.168.255.100,23); echo $tn-read_till(ogin: ); $tn-write(admin\r\n); echo $tn-read_till(word: ); $tn-write(thieso\r\n); echo $tn-read_till(: ); $tn-write(ps\r\n); echo $tn-read_till(: ); echo $tn-close(); ? - Original Message - From: Warren Vail [EMAIL PROTECTED] To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Saturday, June 30, 2001 2:01 PM Subject: RE: [PHP] Telnet and PHP By active user input, I would assume that you mean every time the user makes a keystroke, the keystroke is sent to the host machine. This is not a characteristic of html which only sends information to the host machine when some form of submit is clicked. The advantage of the applet for this sort of thing is it runs on the browser client, and has the capability of sending every keystroke directly to the host, bypassing the server side. On the server side, once the (PHP) application is done sending the requested files to the web browser for one user, it moves on to handling the requests for other users. Can you imagine the load on a server if it had to reload your application every time, your user pressed a key. You never really made it clear where you expected this client to run, although PHP, at this point, can only run on the server. Now if you are looking for something that your PHP code could use to 1. signon to a host somewhere, 2. execute some commands, 3. capture and process the results and 4. disconnect before completing a single page to a web browser client (it will probably never do active user input, because of the nature of PHP and the web server), then I would suggest you consider rexec, rcp, rsh or if what you want is in a file on the host machine, you could use the ftp functions. These are not telnet, and do require special deamons running on the host machine, but may do the trick. I have been looking for your telnet client for a long time as well, and if you find one, please remember to post it here, but I would suspect that one of the problems in doing a telnet client in php is that the telnet client needs to be multi-threaded. Perhaps someone will someday take open source like Dave's Telnet and fashion an extension to PHP. Til then, try the options above, Warren Vail -Original Message- From: [EMAIL PROTECTED] [mailto
Re: [PHP] Telnet with php?
I've been messing with popen and telnet recently and I can see the machine connect and show a response but I never get to a login prompt. I'll be fiddling with this some more, maybe we can work on it together? Julia Quoting Brandon Orther ([EMAIL PROTECTED]): Hello, Is there a way to telnet with php? If so does anyone know a good place to find a tutorial on it? Thank you, Brandon Orther WebIntellects Design/Development Manager [EMAIL PROTECTED] 800-994-6364 www.webintellects.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- [ Julia Anne Case ] [Ships are safe inside the harbor, ] [Programmer at large] [ but is that what ships are really for.] [ Admining Linux ] [ To thine own self be true. ] [ Windows/WindowsNT ] [ Fair is where you take your cows to be judged. ] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Telnet with php?
there's fsockopen from which you might make a telnet client, methinks, but you'd have to know the protocol etc... look for it at the manual. Matt Friedman Spry New Media http://www.sprynewmedia.com Lead Programmer/Partner email: [EMAIL PROTECTED] phone: 250 744 3655 fax: 250 370 0436 - Original Message - From: "Brandon Orther" [EMAIL PROTECTED] To: "PHP User Group" [EMAIL PROTECTED] Sent: Friday, February 09, 2001 2:12 PM Subject: [PHP] Telnet with php? Hello, Is there a way to telnet with php? If so does anyone know a good place to find a tutorial on it? Thank you, Brandon Orther WebIntellects Design/Development Manager [EMAIL PROTECTED] 800-994-6364 www.webintellects.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Telnet with php?
If you are just looking for something better than the ms telnet program, look at http://www.chiark.greenend.org.uk/~sgtatham/putty/. it is so much better than telnet. I don't know if that is what you mean, though. Jeff ""Brandon Orther"" [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Hello, Is there a way to telnet with php? If so does anyone know a good place to find a tutorial on it? Thank you, Brandon Orther WebIntellects Design/Development Manager [EMAIL PROTECTED] 800-994-6364 www.webintellects.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]