I have been trying to write a custom .screenrc file TEST as follows
startup_message off
vbell off
caption always "%{= bb}%{+b w}%n %h %=%t %c"
hardstatus alwayslastline "%-Lw%{= BW}%50>%n%f* %t%{-}%+Lw%<"
activity "Activity in %t(%n)"
shell -/bin/bash
chdir /path1
screen -t WINDOW1 bash -c 'MYSCRIPT1'
chdir /path2
screen -r WINDOW1 bash -c 'MYSCRIPT2'
I am running this script as follows
screen -c TEST
What I am trying to achieve is execute a screen command that spawns two windows in two different directory paths and in each of them two different commands/scripts should be run.
but using this code my screen immediately terminates which is the default behavior.
I want that screen windows should not be terminated rather they should come back to the directory path1 directory path2 respectively once the command terminates in each of these screen windows.
I resolved this as follows. Written a startup script called STARTSCRIPT with below content
It is important to note double quotes(“) on the next line of the command, without it command will not execute.
Also I moved screen hard status settings to its own ~/.screenrc file so that every screen window created looks like a tab inside screen session.
I executed the STARTSCRIPT as follows
It gave me the desired output of running commands in their own screen window and these window do not terminate even after the command finishes.