我在 ubuntu 16.04 上使用 python=2.7
和 pexpect=4.5.0
这是代码:
telnet.sendline("ls --color=never | grep -v bootimage | xargs -n1 rm -rf")
我正在从我的 ubuntu 计算机将此行发送到嵌入式 linux 机器,我在 virutalenv 中。
然而,这台嵌入式机器得到的是:
ls --color=never | grep -v bootimage | xar gs -n1 rm -rf
我的意思是,为什么 xargs
变成了 xar gs
...???我该如何解决?
注意: 1.我还发送了其他更短的命令,它们很好。 2. 曾经很好。这种情况不会一直发生。
最佳答案
使用原始字符串可能是更好的选择,例如 telnet.sendline(r"ls --color=never | grep -v bootimage | xargs -n1 rm -rf")
关于 python ,预计: sendline() adding unexpected whitespace in sending text,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50532593/