【发布时间】:2012-08-28 14:17:17
【问题描述】:
在BusyBoxcommand for Linux 中存在命令microcom 与串行调制解调器通信:
BusyBox v1.13.2 (2012-05-10 17:13:08 CEST) multi-call binary
Usage: microcom [-d DELAY] [-t TIMEOUT] [-s SPEED] [-X] TTY
Copy bytes for stdin to TTY and from TTY to stdout
Options:
-d Wait up to DELAY ms for TTY output before sending every next byte to it
-t Exit if both stdin and TTY are silent for TIMEOUT ms
-s Set serial line to SPEED
-X Disable special meaning of NUL and Ctrl-X from stdin
我不想使用标准输入键入 AT 命令,而是将它们放入一个文本文件中,并将该文件的内容重定向为上述命令的标准输入。比如我有一个文件
/tmp/at.txt
使用 AT 命令AT,通常由 TTY 以OK 确认。使用标准输入的标准会话如下所示:
microcom -t 3000 -X /dev/ttyS5
at
OK
其中字符串at 是直接在键盘上输入的。为了使用文件/tmp/at.txt 的内容(只包含'at\n')。去做这个,。我尝试了以下变体:
microcom -t 3000 -X /dev/ttyS5 < /tmp/at.txt
microcom -t 3000 /dev/ttyS5 < /tmp/at.txt
cat /tmp/at.txt | microcom -t 3000 /dev/ttyS5
tail -f /tmp/at.txt | microcom -t 3000 /dev/ttyS5
cat /tmp/at.txt | microcom -t 3000 /dev/ttyS5 -X
tail -f /tmp/at.txt | microcom -t 3000 /dev/ttyS5 -X
它们都不起作用,即这些命令都没有在屏幕上返回文本“OK”。因此,我得出结论,将文件/tmp/at.txt 的内容重定向为命令microcom 的标准输入存在一些问题。也许与如何解释行尾或文件结尾有关。如果有人有一些想法,我将不胜感激。
谢谢,
亚历克斯
【问题讨论】:
标签: linux redirect pipe stdin tty