#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Posts
    2
    Rep Power
    0
    I trying to create a telnet like program base on web page. Is there anyone have example about this ?

    Sorry for my poor English.

    Best Regards,
    Sittidej K.
  2. #2
  3. Banned (not really)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 1999
    Location
    Brussels, Belgium
    Posts
    14,646
    Rep Power
    4492
    I've seen these written in Java before, but I don't think you can do it in PHP.....feel free to prove me wrong..

    ---John Holmes...
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    300
    Rep Power
    15
    There is much more to telnet than meets the eye. There is no way for you to open up a socket, for example, and simply print to it. Telnet protocol uses some control characters. The best way would be to use Perl and its Net::Telnet module (available from CPAN).
  6. #4
  7. No Profile Picture
    Gödelian monster
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jul 1999
    Location
    Central Florida, USA
    Posts
    2,307
    Rep Power
    62
    ... and I say yes, you can.

    PHP can open a socket, but that's not even necessary to do a telnet client in PHP.

    PHP can pass commands to the system, and it can read standard output. What more do you need? All telnet is, is a method to enter commands to the system and read standard output.

    I agreee it would be a difficult application to build, one which I think would require a fair amount of Javascript and frames to accomplish smoothly, but it's totally possible.

    I don't have any examples to show you, but I would recommend going to the documentation on the PHP site and studying the following PHP functions:

    system()
    exec()
    escapeshellcmd()
    passthru()
    fwrite()
    fputs()
    fsockopen(), pfsockopen
    All of the network functions
    All of the posix_* functions
    All of the filesystem functions

    By the time you are done, you will realize PHP has a very rich set of system functions to accomplish pretty much anything on the server. Be careful; anyone with access to your 'telnet client' PHP page can own your system.
  8. #5
  9. No Profile Picture
    freebsd
    Guest
    Devshed Newbie (0 - 499 posts)
    >>PHP can open a socket, but that's not even necessary to do a telnet client in PHP.
    >>What more do you need? All telnet is, is a method to enter commands to the system and read standard output.

    That is limited to localhost. Telnet by all means is to connect to remote host.

    >>The best way would be to use Perl and its Net::Telnet module (available from CPAN).

    I would agree with dwarf - "The BEST WAY".
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    59
    Rep Power
    15
    But, if you were using linux, couldn't you use the pass_thru (I think) function to do a system call to telnet, and then display and pass input, I know you could get it display, but I suppose the big thing would be to actually give input to the telnet program, and have it pass it.

    Chris
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Location
    Seaside, CA
    Posts
    84
    Rep Power
    15
    There's a beginning of a phptelnet thingy here:
    http://alfalinux.sourceforge.net/pcom.php3

    Here's the description from the web site:

    "Pcom is a PHP-driven webtelnet, that is a web interface to execute shell commands/external programs on a server. Obviously there are limitations, derived mainly by security limitations on the webserver (ie safe_mode in php). There is also a limitation on the program function itself, because you can only use non-interactive commands: you can launch a command or a program that doesn't need user interaction, but you cannot use something like lynx or irc (you can onlylaunch an interactive application in background, driving it automatically by arguments and/or scripts -where possible-). Remember that you can only launch a command, you don't drive a real shell. So, if you launch a ping it will go forever because you cannot take back the control on the stdin, while launching a traceroute you should get back control and output of the command because it terminates itself without user interaction. "

    I haven't tried it but I've been tempted 'cause I don't like doing telnet stuff.

    ------------------
    From the day we're born, we're running out of time.
  14. #8
  15. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Posts
    2
    Rep Power
    0
    Thank you very much for all of your answer. I see some point to go on my work now.
  16. #9
  17. No Profile Picture
    Gödelian monster
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jul 1999
    Location
    Central Florida, USA
    Posts
    2,307
    Rep Power
    62
    >>That is limited to localhost. Telnet by all means is to connect to remote host.

    ...and once you are connected to localhost, all it takes to telnet elsewhere is to enter the command "telnet [otherhost]" and view the standard output.

    I don't see the problem here.
  18. #10
  19. No Profile Picture
    freebsd
    Guest
    Devshed Newbie (0 - 499 posts)
    >>all it takes to telnet elsewhere is to enter the command "telnet [otherhost]" and view the standard output.
    >>I don't see the problem here.

    The problem is, you can't even run that "telnet" command.

    Even Joel's Pcom is a PHP-driven webtelnet suggestion is not a real solution. That's still limited to localhost which absolutely defeat the purpose of Telnet.

    All your PHP ways in this thread is just sending commands and talking to the local system. Calling it Telnet is a misleading term. It should be called "commander" instead.

    With all being said, I am not saying PHP can't perform the task, but Net::Telnet is definitely a way better choice, if someone comes up with a real solution, I'd be glad to hear. Note, I am talking about a web-based telnet interface that enables you to connect ANYWHERE thru Telnet protocol.
  20. #11
  21. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    10
    Rep Power
    0
    hmm.. ya ain't gettin' the point here!
    ya can open a process telnet(ya know DA application, da same one yer usin' in shell?) and write stuff there. Like when ya do a some formmail script that uses sendmail and not mail() there ya open a sendmail process and write data there...

    ------------------
    WizActive
    wizactive@jimportal.com
    http://www.jimportal.com/
  22. #12
  23. No Profile Picture
    freebsd
    Guest
    Devshed Newbie (0 - 499 posts)
    >>ya can open a process telnet and write stuff there.

    Example?

    >>Like when ya do a some formmail script that uses sendmail

    The Perl way is a piece of cake. If you don't have an example of Net::Telnet using PHP, then you should be the one not gettin the point here.

    In case PHP can't perform such task, you don't have to defense PHP, there is always an alternative -> Net::Telnet. Enough said.
  24. #13
  25. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    300
    Rep Power
    15
    Another problem: you cannot simply run telnet, then tell it to do something, capture the output and display it to the user. Telnet waits its commands from the standard input, and I think that in its case is the shell.

    Perl is the easiest way here. Note that PHP was never meant for something like this, while Perl was (sort of).
  26. #14
  27. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Posts
    16
    Rep Power
    0
    This may be oversimply-fying the question, but this is what I use for our web site:

    telnet://xxx.xxx.xxx.xxx/ (as a link)

    Granted, I assume that our clients are either running Windows NT or Win9x.

Similar Threads

  1. Replies: 2
    Last Post: August 18th, 2004, 11:45 PM
  2. Replies: 4
    Last Post: January 28th, 2004, 09:29 AM
  3. PHP with UnixODBC
    By coder4hire in forum PHP Development
    Replies: 2
    Last Post: January 20th, 2004, 02:14 PM
  4. Passing string from PHP to Javascript
    By ka8oad in forum JavaScript Development
    Replies: 4
    Last Post: January 17th, 2004, 04:12 PM
  5. UnixODBC + PHP + Apache + Empress
    By coder4hire in forum Database Management
    Replies: 0
    Last Post: January 15th, 2004, 02:41 PM

IMN logo majestic logo threadwatch logo seochat tools logo