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
2. when login prompt, type xxx
3. when password prompt, type zzz.
4. run the command sh run.

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

Expert 100+
P: 1,584

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);
  6. if(!$connect){
  7.     echo 'fail';
  8. }
  9. else{
  10.     echo 'pass';
  11. }
  12. ?>
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.