happypc
08-03-2007, 06:22 PM
I am trying to get php to dynamically interact with a telnet session, so that it will connect, get header output, execute a command, return the results, and then end the session.
For example, I might want to get it to execute:
"telnet $host 110"
output the header result, evaluate if it is a valid header, then run the following commands in the session, returning the output as strings for display and evaluation:
"user $username"
"pass $password"
"list"
"quit"
I have tried using shell_exec(), passthru(), and system() just to get the initial connection headers; they all output that the connection was succesful, but don't show the headers.
1. How do I get output from a telnet session?
2. How do I send from additional commands after the session was open and return the outs from those?
I am currently working with PHP Version 5.1.6 running on Apache/2.2.2, Fedora Core 5.
For example, I might want to get it to execute:
"telnet $host 110"
output the header result, evaluate if it is a valid header, then run the following commands in the session, returning the output as strings for display and evaluation:
"user $username"
"pass $password"
"list"
"quit"
I have tried using shell_exec(), passthru(), and system() just to get the initial connection headers; they all output that the connection was succesful, but don't show the headers.
1. How do I get output from a telnet session?
2. How do I send from additional commands after the session was open and return the outs from those?
I am currently working with PHP Version 5.1.6 running on Apache/2.2.2, Fedora Core 5.