Telnet from PHP
Posted by neo (The Architect), 5 December 2005I was trying to telnet to a unix machine from within my PHP script, using...
When I login in maually I alwasy get a message saying "WARNING this machine is protected ... blah .. blah..." before the login prompt. So I was expecting to see this in the output of the exec command().
I also tried the passthru() command but still do not see the message in its output. What I get is this
How can make sure I am getting the login prompt after this and then try to login?
Has anyone done telnet logins with PHP before?
Any help would be great.
Posted by admin (Graham Ellis), 5 December 2005You may do better to work at a "higher level" - have a look at the sample code at http://www.geckotribe.com/php-telnet/ which uses a public domain class that you can see at http://www.geckotribe.com/php-telnet/PHPTelnet.php.
If this class isn't ideal for you, then I think you'll do better to use the socket approach that it has within it anyway, rather than calling up a local telnet client to act as a bridge. One less component is involved if you go directly at the sockets, and it also means that you have no interaction problems when you come to pass keyboard inputs to your remote telnetd.
PH: 01144 1225 708225 • FAX: 01144 1225 899360 • EMAIL: email@example.com • WEB: http://www.wellho.net • SKYPE: wellho