【发布时间】:2015-10-23 19:20:58
【问题描述】:
我正在尝试编写一个脚本来将 OS X 帐户的密码更新为一个轮换的、集中存储的值。作为学习使用 tclcurl 的前奏,我只想让这个原型脚本工作:
#!/usr/bin/expect
set mgrpassword "newpassword" # this will become a tclcurl command later
spawn passwd manager
expect "New password:"
send "$mgrpassword\n"
expect "Retype new password:"
send "$mgrpassword\n"
puts "\nManager password changed."
exit 0
它运行没有错误,但它什么也不做;经理帐户的密码保持不变。我用 \r 和 \n 都试过了,但这没有任何区别。谁能看到我做错了什么或我省略了哪些步骤?
(它将始终以管理员权限运行;这就是为什么没有 'expect "Old password:"' 行。)
【问题讨论】:
标签: macos shell expect change-password