管道超时cmd到grep需要根

管道超时cmd到grep需要根,grep,timeout,bluetooth-lowenergy,raspberry-pi3,piping,Grep,Timeout,Bluetooth Lowenergy,Raspberry Pi3,Piping,这里是狂欢节。尝试为家庭助理编写一行BLE标签存在检测器(RPI-3上的内置BLE模块显著降低了家庭助理的速度) 需要一些帮助来完成这项工作: $ timeout -s SIGINT 5s hcitool -i hci0 lescan | grep 00:00:00:00:00:00 $ (timeout -s SIGINT 5s hcitool -i hci0 lescan | grep 00:00:00:00:00:00) 发生了什么(或应该发生什么): hcitool运行5s(优雅地杀

这里是狂欢节。尝试为家庭助理编写一行BLE标签存在检测器(RPI-3上的内置BLE模块显著降低了家庭助理的速度)

需要一些帮助来完成这项工作:

$ timeout -s SIGINT 5s hcitool -i hci0 lescan | grep 00:00:00:00:00:00
$ (timeout -s SIGINT 5s hcitool -i hci0 lescan | grep 00:00:00:00:00:00)
发生了什么(或应该发生什么):

  • hcitool运行5s(优雅地杀死5s后)
  • 输出通过管道传输到grep以检测一个特定MAC
  • 命令返回匹配的mac
  • 但是,此命令不返回任何内容,只返回状态代码130($echo$?)

    然而,这是可行的:

    $ sudo timeout -s SIGINT 5s hcitool -i hci0 lescan | grep 00:00:00:00:00:00
    
    是的,我已经设置了此线程中描述的缺少的上限:

    由于设置了功能,它也可以正常工作(返回检测到的设备列表,在5秒后优雅地终止:

    $ timeout -s SIGINT 5s hcitool -i hci0 lescan
    
    我做错了什么?为什么它看起来需要根?(因为我知道它不应该)

    致以最良好的祝愿

    斯蒂芬解决了这个问题;)

    似乎是执行顺序:)。使用sudo的效果与使用: