[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Sending commands to a process which runs inside screen
From: |
Andrew McGlashan |
Subject: |
Re: Sending commands to a process which runs inside screen |
Date: |
Thu, 21 Apr 2011 02:13:05 +1000 |
User-agent: |
Thunderbird 2.0.0.24 (Windows/20100228) |
Hi,
Stefan Kuhlemann wrote:
I'm looking for a solution for a problem which keeps nagging me for
quite some time...
This might help.
[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 create desired output
/bin/ls
echo -e "======================="
) 2>&1 > $TMPFILE
--
Kind Regards
AndrewM
Andrew McGlashan
Broadband Solutions now including VoIP