How to send a command to /dev/ttyXX

How to send a command /dev/ttyXX.

I've tried these and none seem to worK;
1. echo "stop" > ttyS1
2. echo -ne "stop\n" > ttyS1
Who is Participating?
Duncan RoeConnect With a Mentor Software DeveloperCommented:
You cannot do what you have asked. The only way to get input to ttyS1 is to provide it on the associated serial interface (if there is one).
echo bar > foo and cp baz foo (where baz contains the single line bar) are identical in effect.
Dr. KlahnPrincipal Software EngineerCommented:
The linux "echo" command operates only on its host terminal.  Try putting text into a file, and then

cp (filename) /dev/ttyS1
Duncan RoeConnect With a Mentor Software DeveloperCommented:
Your command echo "stop" > ttyS1 would have worked in that a serial device attached to that connection would have received "stop\n". I don't have a serial port, so I sent to tty1 (console 1) instead. Then I switched to console 1 by Ctr-Alt-F1 and could see that "stop" was displayed.
Duncan RoeSoftware DeveloperCommented:
The question author has not seen fit to comment, so we have to assume he is satisfied with the answer provided.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.