python expect

2020-01-10 11:05:44 浏览数 (1)

代码语言:javascript复制
#!/usr/bin/python
import pexpect
foo = pexpect.spawn('passwd mqjia')
foo.expect("New UNIX password:")
foo.sendline("1234567")
foo.expect("Retype new UNIX password:")
foo.sendline("1234567")
foo.interact()

0 人点赞