Mailing List Archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[tlug] Expect: looping until there is no more input from spawn



Any expect(1) users on this list?

I have a simple script to automate resolving integrations with Perforce:


#!/usr/bin/expect -f

set timeout 30

spawn p4 resolve
while {1} {
    expect {
        "Accept(a) Edit(e) Diff(d) Merge (m) Skip(s) Help(?)" {
            send "at\r"
        } "This overrides your changes: confirm accept (y/n)?" {
            send "y\r"
        }
    }
}


This works fine, but when the "p4 resolve" command finishes, my Expect
script spews the following error:


expect: spawn id exp4 not open
    while executing
"expect -nobrace {Accept(a) Edit(e) Diff(d) Merge (m) Skip(s) Help(?)} {
            send "at\r"
        } {This overrides your changes: confirm accept..."
    invoked from within
"expect {
        "Accept(a) Edit(e) Diff(d) Merge (m) Skip(s) Help(?)" {
            send "at\r"
        } "This overrides your changes: confirm accep..."
    ("while" body line 2)
    invoked from within
"while {1} {
    expect {
        "Accept(a) Edit(e) Diff(d) Merge (m) Skip(s) Help(?)" {
            send "at\r"
        } "This overrides your change..."
    (file "/home/jglover/bin/p4-resolve-accept-theirs" line 44)


I'm sure I need to update the condition in my while loop to test that
exp4 is open, but I am a TCL / Expect novice and don't know how to do
this.

Free pint that the next nomikai (that I attend) for the correct answer. :)

-- 
Cheers,
Josh


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links