0

I would like to control a screen session (A) from another screen session (B). Therefore I wrote a little script that I will run in session B:

#!/bin/sh

clear

while :
do
screen -S SessionA -X stuff '^C'
screen -S SessionA -X stuff 'java -jar jarFile.jar'
screen -S SessionA -X stuff `echo -ne '\015'`

sleep 30
done

So it basically ends the current process of session A and restarts it by sending the java command and an Enter-stroke.

Sending the enter-stroke by using echo -ne '\015' worked flawlessly in the terminal. However, it does not work from the script.

Does anyone know either:
How to send a command to a screen session from a script or simply
How to send an Enter-stroke to a screen session from a script?

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
user3116232
  • 433
  • 5
  • 17

1 Answers1

0

Just found the answer myself. In case someone stumbles on the same problem: Instead of using echo -ne '\015' simply put a ^M at the end of the command.

New script:

#!/bin/sh

clear

while :
do
screen -S SessionA -X stuff '^C'
screen -S SessionA -X stuff 'java -jar jarFile.jar^M'

sleep 30
done
user3116232
  • 433
  • 5
  • 17