【发布时间】:2021-09-10 16:04:33
【问题描述】:
我正在编写一个简单的脚本来检查文件的所有权。这一切都按预期工作,但我在输出中得到了一些随机(或不是)字符。
这是脚本:
import pexpect
p=pexpect.spawn('ssh root@%s'% addr)
p.sendline("ls -l /etc/gshadow")
p.expect("root@system:~#")
print("CMD %s:\n" %p.before.decode())
这是输出
CMD ls -l /etc/gshadow
lrwxrwxrwx 1 root root 15 Jun 22 08:46 /etc/gshadow -> /home/+/gshadow
:
^[[64;5Ruser@system:~/home$ 4;5R
为什么我会在提示周围出现这些字符,如何防止这种情况发生?
【问题讨论】:
-
是
ppexpect? -
p=pexpect.spawn('ssh root@%s'% addr)
-
您应该 edit 您的问题在此处提供该信息,而不是将其隐藏在 cmets 中(尽管现在最简单,如果您只是批准提议的编辑)。
标签: python python-3.x pexpect