Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Possible Duplicate:
sending text input to a detached screen

I have a script for my Minecraft server that runs automatically every 15 minutes. The problem is that after a server reboot, minecraft is automatically started in Gnu Screen. This is ideal, of course, except that for some reason the script (which returns no errors in this case) can't seem to "connect" with the screen if I don't SSH in and manually attach, then detach the screen.

The script runs, but nothing happens within the screen. I have checked that I am the owner of the screen (as opposed to a system owner), and it checks out. The screen exists, and is titled properly, and everything seems like it should be working.

But if I don't login to attach the screen manually first, my script can't communicate with the screen.

Does anyone have any clue why this is and how I can work around it?

share|improve this question

marked as duplicate by Caleb, Gilles, Michael Mrozek Aug 8 '11 at 6:02

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1  
This is a known wonkyness in screen that has been discussed in relation to minecraft specifically on this question. There are solutions to make screen behave and explanations of how to switch to tmux which is better behaved. –  Caleb Aug 7 '11 at 16:57
    
thanks Caleb. I found that post also after posting myself. I'm going to try to switch over to tmux, I suppose. Or, as an alternative, peruse through the screenutils python module to see if I can add a command to issue the -p attribute when executing commands. –  Tom Aug 7 '11 at 18:01
    
We can't help without seeing the script. But your problem does sound a lot like the earlier one already indicated by Caleb. –  Gilles Aug 7 '11 at 18:19

1 Answer 1

I bet it is an environment thing. Try running the command wrapped with su - -c user 'screen ...'. That will set up a login shell for user, so the environment should look the same as when you login via ssh.

share|improve this answer
    
Screen has an issue where if you create a detached session it doesn't focus the window so you can't send it commands. Attaching/detaching via ssh just forces it to focus the default window and after that it will accept commands. You can also force this from the command line if you know how (see the question this is marked as a duplicate of). –  Caleb Aug 8 '11 at 10:21

Not the answer you're looking for? Browse other questions tagged or ask your own question.