sama Posted April 9, 2010 Share Posted April 9, 2010 Hello mate I have this problem: I use a php script to pass commands to a router via telnet.. this code use another script ( which is attached here). I need to pass an enter, how could I do that? :-\ what character should I put between the quotation? I tried to put 'e' but it doesn't work..please see the code.. <?php session_start(); require_once "PHPTelnet.php"; require_once "password.php"; $telnet = new PHPTelnet(); // using a function from the included script $result = $telnet->Connect('192.168.10.1','',''); //IP address of the router, username, password switch ($result) { case 0: echo "Connected!!"; $telnet->DoCommand('engineer', $result); echo $result; $telnet->DoCommand('sama', $result); echo $result; $telnet->DoCommand('who', $result); // to see the active telnet session echo $result; $telnet->DoCommand('clear line vty 0', $result); // disconnect the active once echo $result; [color=orange]$telnet->DoCommand(' ', $result); //to confirm the disconnect action, it need to press enter button. what should I put? echo $result;[/color] $telnet->DoCommand('exit', $result); echo $result; break; case 1: echo '[php Telnet] Connect failed: Unable to open network connection'; break; case 2: echo '[php Telnet] Connect failed: Unknown host'; break; case 3: echo '[php Telnet] Connect failed: Login failed'; break; case 4: echo '[php Telnet] Connect failed: Your PHP version does not support PHP Telnet'; break; } ?> [attachment deleted by admin] Link to comment https://forums.phpfreaks.com/topic/198080-telnet-command-through-php/ Share on other sites More sharing options...
sama Posted April 9, 2010 Author Share Posted April 9, 2010 please I need help :'( read my post.. Link to comment https://forums.phpfreaks.com/topic/198080-telnet-command-through-php/#findComment-1039673 Share on other sites More sharing options...
teamatomic Posted April 9, 2010 Share Posted April 9, 2010 What you need to use is a carriage return, \r, should work just fine. HTH Teamatomic Link to comment https://forums.phpfreaks.com/topic/198080-telnet-command-through-php/#findComment-1039709 Share on other sites More sharing options...
BionicClick Posted February 20, 2013 Share Posted February 20, 2013 Hello, I sure am glad to see people using this PHP to preform this task. I am in need of doing so right now. I have a website that I need to connect to a web server running nothing but telnet basically... I need to send a command and get the response. Would you be willing to share the entire script your using? My Best, Jason PS, Im so happ the /r would work, now SAMA, did the /r carriage return work? Link to comment https://forums.phpfreaks.com/topic/198080-telnet-command-through-php/#findComment-1413670 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.