Get a return value from a screen'd command

Posted by AndyMac on Stack Overflow See other posts from Stack Overflow or by AndyMac
Published on 2013-10-21T21:50:32Z Indexed on 2013/10/21 21:53 UTC
Read the original article Hit count: 139

Filed under:

I'm running a process in a screen (on Ubuntu 13.10, if it matters). I can execute a command within that screen with: screen -p 0 -X eval 'stuff \"$command\"\015'

I'm not 100% sure what this command is doing to begin with, though it's functioning correctly. The reason behind it is I'm running a Minecraft server (still) and this screens in to the correct screen, and throws the command on the running command line. So that's good, so far.

But what I'd like is to be able to run this command with a return value. So for example, if I were to run a "list" command, it'd tell me how many people and who is online, but I need to capture that output and put it somewhere.

Anyone know of a way to accomplish this? I can't tell the minecraft server command line to redirect the output somewhere else since it doesn't have direct command line access, so the only way I could do this would be to grab all output of the screen while I'm connected ... but I'm not sure if that's possible.

© Stack Overflow or respective owner

Related posts about gnu-screen