Question

I am sending commands to a Windows server using Cygwin. I asked a question for a few days ago but it remained unanswered. I have a big issue with phpseclib and it's $ssh->write(); command. I've used $ssh->exec(); but the command sent to the server is downloading game server files which can take up to 20 minutes and after awhile the php page times out because it exceeds the FastCGI timeout setting. So, I thought that $ssh->write(); could solve it for me but the command I'm sending to the server doesn't get executed. Here's the command for the exec and the write I'm trying to use:

$ssh->exec('C:/hldsupdatetool/hldsupdatetool -command update -game ".$game." -dir ".$dir');

and this code loads forever and then times out. I've solved this with changing FastCGI's timeout setting to one hour which is the max. This command DOES get executed on the server.

This is the write command I'm trying to send but doesn't execute:

$ssh->write('C:/hldsupdatetool/hldsupdatetool -command update -game ".$game." -dir ".$dir."\r\n");

This command DOES NOT get executed on the server. The response I get from it when echoing it is "1".

Any help is highly appreciated! Currently making an Open-Source Game Server Control Panel.

Thanks in advance!

Best Regards, Tom.

Was it helpful?

Solution

To read the response of $ssh->write() you need to do $ssh->read(). eg.

http://phpseclib.sourceforge.net/ssh/examples.html#interactive

$ssh->write() is outputting 1 because $ssh->write() is returning true.

Anyway, something you could try... $ssh->setTimeout(5) or whatever.

I don't know if it's possible to send Windows commands to the background? With Linux there's nohup and &.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top