Shell script start 1 session with multiple windows
The command you can send with -X
option is not shell command but screen command.
Check CUSTOMIZATION section in man screen
to see the list of screen command.the following code uses screen
command to create new window and stuff
command to show text on the window.
#!/bin/bashscreen -d -m -S mysession# window 0 is created by default, show hello0 on itscreen -S mysession -p 0 -X stuff hello0for n in {1..9}; do # create now window using `screen` command screen -S mysession -X screen $n screen -S mysession -p $n -X stuff hello$ndone
Now you can attach to myscreen
session and check that there are 10 windows and hello0 .. hello9 is displayed in each window.
$ screen -r mysession[Press C-a "]