Skip to content

Instantly share code, notes, and snippets.

Created February 25, 2018 05:33
Show Gist options
  • Save anonymous/73432240e4ed4361e398dde64dc2877d to your computer and use it in GitHub Desktop.
Save anonymous/73432240e4ed4361e398dde64dc2877d to your computer and use it in GitHub Desktop.
retcode ERR_UNKNOWN_PWD_OUTPUT 1 "The `pwd` command returned an unexpected output: $output"
retcode ERR_PASSWORD_DIDNT_SUCCEED 2 "The `pwd` command accepted the input but didn't succeed: $output"
retcode ERR_CONFIRM_DIDNT_SUCCEED 3 "The `pwd` confirmation accepted the input but didn't succeed: $output"
retcode ERR_UNKNOWN_SUDO_OUTPUT 4 "The `sudo` command returned an unexpected output: $output"
ssh andrew@foo.bar.baz
runPwd($argv[0])
case success next
case "You are not root" return rootPwd($argv[0])
else return $!
def runPwd ($pass) {
case "Enter camilo's password" {
send $pass
case success next
else return ERR_PASSWORD_DIDNT_SUCCEED
}
case "Confirm camilo's new password {
send $pass
case success next
else return ERR_CONFIRM_DIDNT_SUCCEED
}
else return ERR_UNKNOWN_PWD_OUTPUT
}
def rootPwd ($pass) {
send "sudo pwd camilo" {
case "Enter your root password" prompt
send $argv[1]
next
else return ERR_UNKNOWN_SUDO_OUTPUT
}
runPwd($pass)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment