Originally Posted by
CharlesA
I used to use:
Code:
screen -d -m script.sh
The screen session will start detached, but will close once the script is finished.
I think you misunderstood. The script never finishes; it launches a server with a prompt. I'm injecting commands into the prompt with 'screen -S pie -X stuff', but it only works after it's been entered with screen -r pie and then detached again. I have no idea what causes this behavior or how to get around it.
----------------------------------
EDIT: Here's how you can try it yourself.
Code:
screen -d -m -S pie
screen -S pie -X stuff $'\necho pie\n'
screen -S pie -X stuff $'\necho pie\n'
screen -S pie -X stuff $'\necho pie\n'
screen -S pie -X stuff $'\necho pie\n'
screen -r pie
You can see that the commands did not get inserted into the screen session.
Then detach the screen with ctrl+a followed by ctrl+d. Now:
Code:
screen -S pie -X stuff $'\necho yes\n'
screen -S pie -X stuff $'\necho yes\n'
screen -S pie -X stuff $'\necho yes\n'
screen -r pie
Now the commands did get inserted into the screen session. I need a way to get to this point without human input. I don't understand why it doesn't work to begin with.
Bookmarks