0

I have a shell script that makes a backup of my server files before starting it. However I wish it to instead of just running it open a new screen session and then start it from there. Once its running I want to periodically send commands to it.

Anyone know how to run screen like this?? I have found tons of stuff but very little of it assumes I'm running it from a shell script (instead of just typing it into the terminal window).

Bart De Vos
  • 17,911
  • 6
  • 63
  • 82
bbq
  • 1

1 Answers1

1

If I'm understanding you right, you can do it this way.

To launch the shell script in a screen session:

screen -dmS MyScreenSession sh myShellScript.sh

Thereafter, if you want to send commands to the script without having to bring up the screen session, you can use this command:

screen -p 0 -S MyScreenSession -X eval 'stuff "Some command goes here"\015'