Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Aug 2007
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Getting PHP to interact with Telnet session

    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:

    Code:
    "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:

    Code:
    "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.

  • #2
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,073
    Thanks
    11
    Thanked 98 Times in 96 Posts
    telnet requires a challenge-response process so you need to write a daemon that will send data to and listen for data from the telnet server, in other words you need to write your own socket server.

    Might be easier to start off with one already written,
    http://www.geckotribe.com/php-telnet/
    I have no knowledge of this script BTW its just the first one that google gave me..
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •