How to send a command to /dev/ttyXX

Monty
Monty used Ask the Experts™
on
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
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Dr. KlahnPrincipal Software Engineer

Commented:
The linux "echo" command operates only on its host terminal.  Try putting text into a file, and then

cp (filename) /dev/ttyS1
Software Developer
Commented:
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.
Duncan RoeSoftware Developer
Commented:
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 Developer

Commented:
The question author has not seen fit to comment, so we have to assume he is satisfied with the answer provided.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial