仅列出标题 列出摘要

linux 非交互普通用户修改密码

 1 import pexpect
  2 newpasswd = 'www.baoyiluo.com'
  3 oldpasswd = 'www.longgeek.com'
  4 child = pexpect.spawn('passwd')
  5 child.expect('(current).*:')
  6 print 'old over'
  7 child.sendline(oldpasswd)
  8 child.expect('New password.*:')
  9 child.sendline(newpasswd)
 10 print 'first'
 11 child.expect('Retype new password.*:')
 12 child.sendline(newpasswd)
 13 print 'second'

posted on 2013-01-17 11:09  baoyiluo  阅读(405)  评论(1编辑  收藏  举报