Hopefully the SEO magic of my title will help some other people searching for this.
I spent the last day or two looking for a solution to send a command to a screen in unix. A screen is basically a backgrounded session that you can run programs in. It’s a shoddy explanation, so go google what it REALLY is.
Anyway, a really simple way to send a command to a screen is this:
First, create the screen and detach it:
screen -dmS nameofscreen
Now we can send commands to it!
screen -S nameofscreen -X eval “stuff ‘COMMAND’\015”
This is a super basic way to send a command and “hit enter” after it, and the screen will run whatever you put in. This was seriously the only way that worked for me, so let me know if there is something more simple.