0

If I use phpseclib to continue a screen it does not work the way I want to.

If I use:

    <?php
include('Net/SSH2.php');

$ssh = new Net_SSH2('XXX.XXX.XXX.XXX');
if (!$ssh->login('loginname', 'password')) {
    exit('Login Failed');
}

echo $ssh->write("screen -R minecraft\n");
echo $ssh->exec("cd /home/ftpmc/mc/; java -Xmx4096M -Xms4096M -jar craftbukkit.jar nogui");
?>

It then comes up with 1 and then starts up the minecraft server but not in the screen. Is there an alternative that is known to work well with phpseclib or is there something i'm doing wrong here?

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Paul de Koning
  • 422
  • 1
  • 5
  • 16
  • idk anything about screen but I will say that write() and exec() operate in different channels. So it's kinda like what you're doing is... you have two PuTTY windows and in one of them you type in `screen -R minecraft` and in the other you type `cd /home/ftpmc/mc/; java -Xmx4096M -Xms4096M -jar craftbukkit.jar nogui`. idk if that insight helps.. – neubert Dec 13 '16 at 03:17

1 Answers1

1

neubert is on the right track, give the commands you want to execute (in the example it is 'vim') as additional arguments to the 'screen' command like this:

screen -S minecraft -X stuff 'cd /tmp; vim^M'
ma-ti
  • 126
  • 8