#!/usr/bin/expect --
# -*- mode: tcl; tab-width: 8; encoding: utf-8-unix -*-

set timeout 60

set elt $env(keyserver)

spawn gpg --verbose \
	--homedir  $env(HOMEDIR) \
       --debug-level guru \
       --keyserver hkp://$elt \
       --search-keys $env(KEY_ID)

# keyserver search failed: Not found
# 0x6923CE7991ABF7338DB1C9AA5F0142A080E4A9A0

expect "1-1*"
send_user "Sending 1\r"
send "1\r"

expect -re .+ {
    exp_continue
  } 0x6923CE7991ABF7338DB1C9AA5F0142A080E4A9A0 {
    send_user "Quitting 0x6923CE7991ABF7338DB1C9AA5F0142A080E4A9A0\r"
    exit 0
  } AbCdEfGhIj {
    send_user "Quitting AbCdEfGhIj\r"
    exit 0
  } BYE {
    send_user "Quitting BYE\r"
    exit 0
  } "6923 CE79 91AB F733 8DB1  C9AA 5F01 42A0 80E4 A9A0" {
    send_user "Quitting FP\r"
    exit 0
  } timeout {
    exit 1
  } eof {
    exit 0
  }


# expect -r .+ {send "\r"}
