1

I have a local script that runs a remote script via ssh. The local script is minecraft.php:

ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i {$this->pemkey} {$this->ssh_user} sudo /vol/start_bukkit.sh 

The remote script is /vol/start_bukkit.sh:

#!/bin/bash cd "/vol/bukkit" /usr/bin/screen -S bukkit -m -d /usr/local/bin/java -Xnoclassgc -Xms1024M -Xmx1024M -jar /vol/bukkit/craftbukkit.jar nogui 

What happens is that the java command works, launching craftbukkit.jar, but screen doesn't launch a new window. What's going on? How can a new window be created?

If I sign in to the remote server and run start_bukkit.sh then screen works as expected, creating a newly detached window running craftbukkit.jar in it.

EDIT:

I got it to work. I updated the local script by removing the sudo and putting the screen command in. Here it is:

ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i {$this->pemkey} {$this->ssh_user} /usr/bin/screen -S bukkit -m -d /vol/start_bukkit.sh 

On the remote side I removed the screen command:

#!/bin/bash cd "/vol/bukkit" /usr/local/bin/java -Xnoclassgc -Xms1024M -Xmx1024M -jar /vol/bukkit/craftbukkit.jar nogui 

I can't explain why this works.

1 Answer 1

1

Try forcing a psuedo-tty with your ssh command.

ssh -t -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i {$this->pemkey} {$this->ssh_user} sudo /vol/start_bukkit.sh man 1 ssh -t Force pseudo-tty allocation. This can be used to execute arbitrary screen-based programs on a remote machine, which can be very useful, e.g. when implementing menu services. Multiple -t options force tty allocation, even if ssh has no local tty. 

Also, in your script start_bukkit.sh, you don't have a PATH set. You call java without an absolute path, so it may not be found. Either set a PATH at the beginning of the script (best practice), or call java via the absolute path (/usr/bin/java).

2
  • If I add ssh -t option then the screen window is not created AND the java program is not started. Commented Jun 26, 2012 at 17:49
  • BTW, I updated java to the absolute path. Commented Jun 26, 2012 at 17:51

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.