How to execute telnet php command

I have code to connect to teampeak server with telnet. can someone help me send a command?

my code is:

<?php
$ip = 'localhost';
$result = '';
$fp = fsockopen($ip, 10011); 
echo fgets($fp); 
      fputs($fp,"help");
      $result=fread($fp,1024); 
fclose($fp);
echo nl2br($result);
?>

I want to send the command "help"

this code only returns:

TS3 
Welcome to the TeamSpeak 3 ServerQuery interface, type "help" for a list of commands and "help " for information on a specific command.
+4
source share
1 answer

something like that:

<?php
$socket = fsockopen("localhost", "10011", $errno, $errstr); 

if($socket) 
{ 
    echo "Connected <br /><br />"; 
} 
else 
{ 
    echo "Connection failed!<br /><br />"; 
} 

fputs($socket, "help \r\n"); 

$buffer = ""; 

while(!feof($socket)) 
{ 
    $buffer .=fgets($socket, 4096); 
} 

print_r($buffer); 
echo "<br /><br /><br />"; 
var_dump($buffer); 

fclose($socket); 
?> 

I added something else to your code, it was impossible

+4
source

Source: https://habr.com/ru/post/1540747/


All Articles