#!/usr/bin/expect

set timeout 10
set response [lindex $argv 0]
set argv [lreplace $argv 0 0]

spawn {*}$argv

# timeout handler
proc itstime {args} {
    puts "!! expect timeout !!"
    exit 1
}

while {1} {
    expect {

        eof {
            break
        }

        timeout {
            itstime
        }

        "The problem has only occurred once and the ability to reproduce the problem is unknown. Please ensure you will be able to provide detailed information to our Support Team. Would you like to continue and open a new support case?" {
            puts "GOT QUESTION: count"
            send "$response\n"
        }

        -re "The crashed program was released by '.*'. Would you like to report the problem to Red Hat Support?.*" {
            puts "GOT QUESTION: vendor"
            send "$response\n"
        }

        -re "The program '.*' does not appear to be provided by Red Hat. Would you like to report the problem to Red Hat Support?.*" {
            puts "GOT QUESTION: package"
            send "$response\n"
        }
    }
}


