Posts

Showing posts from August, 2014

Sending commands to a process which runs inside screen

Sending commands to a process which runs inside screen   [The script screen-test.sh runs the secondary script] NB: nothing gets output in the screen session window itself - if you want that then use tee 2>&1 | tee $TMPFILE cat screen-test.sh #!/bin/sh # Send command to screen session # - if you have more than one screen session, you'll # need to find out the right session and use it # specifically. #screen -r 10345.root -X exec ${PWD}/screen-test2.sh screen -r -X exec ${PWD}/screen-test2.sh # Give job time to complete before continuing.... sleep 1 # Get output file name (was created in other script with mktemp) MYFILE=$(ls -rt /tmp/screen-test.*|tail -1) # Display file and remove it cat $MYFILE && rm $MYFILE cat screen-test2.sh #!/bin/sh TMPFILE=$(mktemp -p /tmp screen-test.XXXXXX) ( echo "+====+ $TMPFILE +====+" echo "Running in dir: $(pwd)" echo "-----------------------" # command(s) to run in session to cre