使用ffsockopen连接到远程机器上以后 然后使用fputs("command") 发送命令..比如fputs("auth ClueCon\n\r\n\r")认证失败
直接使用telnet 执行该命令可以正确返回 是不是\n\r\n\r回车的问题 \n\r\n\r我的意思是代表两个回车请高手们指点!
直接使用telnet 执行该命令可以正确返回 是不是\n\r\n\r回车的问题 \n\r\n\r我的意思是代表两个回车请高手们指点!
Primary codes just like this:
$fp = fsockopen('ip','port');
fputs($fp,'auth ClueCon\r\n\r\n');
while(!feof($fp)){
echo fgets($fp);
}
fclose($fp);That's just authentication, if success, then, I will send some commands. Just like "api get_sys_limit" or others.
I just want to execute some commands in a remote computer and I need get the return value.
Just so simple. How should I do? Many thanks!
$fp = fsockopen('ip','port',$errno,$errstr,1);
if(!$fp)
{
exit('Could not connect to host.');
}
2.如果连接成功就应该是发送的协议串不符合socket server的要求。你试过fwrite($fp,"auth ClueCon\r\n\r\n");了吗?是双引号引起,不是单引号。