By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,255 Members | 2,773 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,255 IT Pros & Developers. It's quick & easy.

How to create a telnet session using php?

P: 4
Anyone can help me to do the following?
Im new to php as i had did it using python but i not sure how to write it in php as it does not have any telnet module.

Write a PHP code using proc_open()

the commands are
1. telnet 10.247.5.3
2. when login prompt, type xxx
3. when password prompt, type zzz.
4. run the command sh run.

thanks!
Mar 16 '12 #1
Share this Question
Share on Google+
2 Replies


dlite922
Expert 100+
P: 1,584
Checkout php.net/fsockopen.

Dan
Mar 16 '12 #2

P: 4
Thanks Dan,

i had tried the following codes -->

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $ip = '192.168.x.x';
  3. $port = '23';
  4. $connect = fsockopen($ip,$port);
  5.  
  6. if(!$connect){
  7.     echo 'fail';
  8. }
  9. else{
  10.     echo 'pass';
  11. }
  12. ?>
  13.  
But how can i input the username and password ?
i had tried fwrite($connect, 'username'); but i dont seem to be working.
Mar 19 '12 #3

Post your reply

Sign in to post your reply or Sign up for a free account.