
Mailing List Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [tlug] Expect: looping until there is no more input from spawn
On Tue, Mar 11, 2008 at 12:00:50PM +0900, Josh Glover wrote:
> 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:
>
Caveat: I don't know Perforce and I'm not an Expect expert.
Does Perforce return anything when it's done? If not, presumably there's
an eof?
Idea #1:
use "system" instead of "spawn" and test for the return value in the
condition
Idea #2:
Use a conditional expect and test for the return value (or eof) in the
loop, and if so, break out:
expect {
eof {
break
}
your stuff
}
Ed
Home |
Main Index |
Thread Index