Reputation: 554
I'm working on a bash script that will connect to a screen and run another bash file, that bash file will then output a bunch of text on the screen.
So far I'm able to start the screen, but I'm unable to connect to the screen, run a bash file, and then see the output.
Here's what I got so far:
SCREEN_NAME="the_screen"
function startScreen(){
echo "Attempting to Start New Screen..."
screen -dmS $SCREEN_NAME
echo "Screen '${SCREEN_NAME}' Started!"
}
function runStartBash(){
echo "Attempting to Run Script..."
screen -S $SCREEN_NAME -X stuff 'sh /home/blob/nox/start.sh"^M'
}
startScreen
runStartBash
start.sh contains a simple loop to print data. It works on its own but can't figure out how to run it through a screen.
Upvotes: 1
Views: 108
Reputation: 47206
Try removing unwanted "
from runStartBash()
screen -S $SCREEN_NAME -X stuff 'sh /home/blob/nox/start.sh"^M'
Make it as:
screen -S $SCREEN_NAME -X stuff 'sh /home/blob/nox/start.sh ^M'
then start the script as 'bash scriptname.sh'
Upvotes: 1