我正在使用Cygwin向Windows服务器发送命令。几天前我问了一个问题,但仍然没有得到回答。我对phpseclib有一个大问题,那就是$ssh->write();命令。我使用了$ssh->exec();但是发送到服务器的命令是下载游戏服务器文件,这可能需要20分钟,一段时间后,php页面会超时,因为它超过了FastCGI超时设置。因此,我认为$ssh->write();可以为我解决这个问题,但是我发送到服务器的命令没有得到执行。下面是我尝试使用的exec和write命令:
$ssh->exec('C:/hldsupdatetool/hldsupdatetool -command update -game ".$game." -dir ".$dir');这段代码永远加载,然后超时。我已经解决了这个问题,将FastCGI的超时设置更改为1小时,这是最大值。此命令在服务器上执行。
这是我试图发送但没有执行的write命令:
$ssh->write('C:/hldsupdatetool/hldsupdatetool -command update -game ".$game." -dir ".$dir."\r\n");此命令不会在服务器上执行。回显时,我得到的响应是"1“。
任何帮助都是非常感谢的!目前正在制作一个开源游戏服务器控制面板。
提前感谢!
最好的问候,汤姆。
发布于 2012-10-27 12:15:12
要读取$ssh->write()的响应,需要执行$ssh-> read ()。例如:
http://phpseclib.sourceforge.net/ssh/examples.html#interactive
$ssh->write()输出1,因为$ssh->write()返回true。
不管怎样,你可以试试...$ssh->setTimeout(5)或其他任何东西。
我不知道是否可以将Windows命令发送到后台?对于Linux,没有and和&。
https://stackoverflow.com/questions/13095434
复制相似问题