I am running a bash file through PuTTY. This is the contents of it:

#!/bin/bash
screen -X 'java -Xms2048m -Xmx2048m -jar mcpc.jar'
screen -x

When I run /backups/turnon.sh, it successfully connects to the screen however the java command is never run. Running the java command through PuTTY works fine. The bash file doesn't break at any point (as screen -x works fine), what's wrong?

有帮助吗?

解决方案

If you have not already, read the answer provided by Gilles here:

In short (to make some redundancy) the -X option expects a command. That is: a screen-command, not a shell/system command.

You could use the stuff-command. I.e.:

screen -X stuff 'java -Xms2048m -Xmx2048m -jar mcpc.jar

'

If you omit the command the target screen should respond with an error like:

-X: unknown command 'java -Xms2048m -Xmx2048m -jar mcpc.jar'

in the running screen window.


Notes:

  • At least here, I have to use double new-line at end of command. (Like example above).
  • As an alternative you can add the control character ^M, typically Ctrl+V Enter in Vim, bash etc. That inserts <CR>, byte 0x0d.
  • mcpc.jar must be in local path or provided by full/relative path.
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top