Reputation: 19
Is it possible to create a screen and execute a command in it without actually open it?
What I need to perform is the following:
screen -S screen_name
)At the moment I need to manually create the screen, then enter it, and then execute the desired command.
Is it possible to do that only via 1 bash command?
Upvotes: 1
Views: 390
Reputation: 11375
Create a screen with in detached mode:
screen -S "scr1" -d -m
Send the command to be executed on your screen:
screen -r "scr1" -X stuff $'ls -lrt \n'
The $ before the command is to make the shell parse the \n inside the quotes, and the newline is required to execute the command (like when you press enter).
Upvotes: 2