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

46 lines
778 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
}
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