1
0
mirror of https://github.com/ansible/awx.git synced 2024-10-30 13:55:31 +03:00
awx/tools/scripts/sign.exp
2015-09-09 18:51:41 -04:00

50 lines
871 B
Plaintext
Executable File

#!/usr/bin/expect -f
#
# Helper script to respond to passphrase prompts from the gpg command.
#
# Disable timeout
set timeout -1
# Optionally print usage message
if {[llength $argv] <= 0} {
puts "Usage: sign.exp <command>"
exit 1
}
# Process arguments
set command [join $argv]
if { [info exists env(PASSPHRASE) ] } {
set passphrase $env(PASSPHRASE)
} else {
set passphrase ""
}
# Run the desired command
spawn {*}$command
expect {
-nocase "enter passphrase:" {
send -- "$passphrase\r"
exp_continue
}
-nocase "enter pass phrase:" {
send -- "$passphrase\r"
exp_continue
}
timeout {
puts "expect timeout"
exit 1
}
eof { }
}
lassign [wait] pid spawnid os_error_flag retval
if {$os_error_flag == 0} {
puts "exit status: $retval"
} else {
puts "errno: $retval"
}
exit $retval