1

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.

1 Answer 1

1

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'

Sign up to request clarification or add additional context in comments.

1 Comment

Wow, didn't even notice that there. Got this working, thanks for the help!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.