1

I want to make a bash script that echo's something into one of the screens that I have running (screen -r is how I get to it in SSH).

I was wondering how I would make the script execute itself in screen -r?

I basically just want the script to say something on a minecraft server through the console and would set up a cronjob to say it every x minutes.

Cheers,

2 Answers 2

2

You can use the -X option of screen to send commands to a running screen session. Also the -p option is useful in this case, as you can use it to preselect a window

As an example you can run a script in a running screen session on windows 0 via:

 screen -p 0 -X stuff './fancy_script.sh^M'

Note, that you have to append the return key-code to execute the script.

Sign up to request clarification or add additional context in comments.

1 Comment

you can do that via: ctrl+v and than Return
0

You can look in /dev/pts. I don't have screen here to test, but you can echo something to an opened terminal with, for example, echo "toto" > /dev/pts/0 (it will be echoed on the first opened terminal).

1 Comment

This doesn't seem to work. I've checked the screen sessions running and have tried echoing stuff into it but nothing seems to appear..?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.