bash 命令 'echo -n -e "\x87" > /dev/ttyAMA0' 无法从 shell 脚本运行

bash command 'echo -n -e "\x87" > /dev/ttyAMA0' not working from shell script

我正在尝试通过 RaspberryPi 控制我的 Roomba vacuum cleaner。但是还是有一些问题。

我需要向串行接口发送一个特殊命令来启动吸尘器。如果我在 Bash 中这样做,它工作正常:

echo -n -e "\x87" > /dev/ttyAMA0

如果我将它放入我的 shell 脚本中,它将不再起作用:

#! /bin/bash
echo -n -e "\x87" > /dev/ttyAMA0

有什么想法吗?

你让脚本可以运行了吗? IE。 chmod +x script.sh。还要确保您 运行 脚本正确 ./script.sh。如需更多帮助,请参阅此 website.