简体   繁体   English

python,pexpect:sendline()在发送文本时添加了意外的空格

[英]python, pexpect: sendline() adding unexpected whitespace in sending text

I am using python=2.7 and pexpect=4.5.0 on ubuntu 16.04 我在Ubuntu 16.04上使用python=2.7pexpect=4.5.0

This is the code: 这是代码:

telnet.sendline("ls --color=never | grep -v bootimage | xargs -n1 rm -rf")

I'm sending this line to an embedded linux machine from my ubuntu computer, i'm in a virutalenv. 我正在从ubuntu计算机将这条线发送到嵌入式linux机器,我在virutalenv中。

However, what this embedded machine gets is: 但是,此嵌入式计算机得到的是:

ls --color=never | grep -v bootimage | xar gs -n1 rm -rf

I mean, why does xargs become xar gs ...??? 我的意思是,为什么xargs变成xar gs ... ??? How do I fix it? 我如何解决它?

Note: 1. I also send other shorter commands, they are good. 注意:1.我还发送了其他较短的命令,它们很好。 2. It used to be good. 2.以前很好。 This does not happen consistently. 这并非始终发生。

使用原始字符串可能是更好的选择,例如telnet.sendline(r"ls --color=never | grep -v bootimage | xargs -n1 rm -rf")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM