PedZad PedZad - 1 year ago 151
Linux Question

Sending a command to screen in linux

In order to run a data analysis program, installed on a Teensy 2.0 microcontroller running arduino, I have to go to the screen by typing

screen -S trans -L /dev/ttyACM0 (the name of the screen is trans).

Once in the new screen, I have to enter 's' to start the scanning process.
I am trying to write a script to automate the process of writing commands, but cannot figure out how to pass 's' into the screen to automatically begin the scanning process.
I have tried commands such as

screen -S trans -X stuff "s$(printf \\r)"

echo "s" > /dev/ttyACM0

I'm working on a Linux Ubuntu OS.
Any help would be appreciated.

Answer Source

What you want is

screen -S trans -X stuff 'command'$(echo -ne '\015')


screen -S trans -X stuff 's'$(echo -ne '\015')

in your case. Let me know if this works for you.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download