LisaY wrote:
> I'm running a non-interactive Tcl app that incorporates an Expect
> loop, spawning and monitoring several concurrent processes (of another
> application). Their spawn_ids are maintained in a list
> (lstSpawnIDs). I'm using the basic syntax mentioned in Exploring
> Expect pg. 292 (for reasons I'll skip for now), coupled with the if/
> catch noted in the following section, pg. 296:
> set strSpawn { spawn -open [open "| myapp args 2>logfile.txt" w
> +] }
> if [catch $strSpawn reason] {
> <perform failure notification using $reason>
> } else {
> <successful spawn>
> :
> }
> expect {
> -i lstSpawnIDs
> default {
> <perform normal eof/timeout handling>
> }
> }
> However I also acknowledge the footnote on pg. 296: " 'spawn -open'
> returns a process id of 0 to indicate no process was spawned. There
> is no process to kill."
> The above code works most of the time, but produces "spawn_id expxxx
> not open" under certain circumstances. This indicates that a spawn_id
> was generated for myapp but some failure occured, closing myapp. I
> have determined that the failure clause above is never invoked,
> whether the spawn/open is successful or not, presumably because of the
> footnote (process ID always = 0).
> So my main question is: What's the best means of determining the
> success/failure of the launch of myapp? I.e. I need to intercept the
> "spawn_id expxxx not open" dialog and take appropriate action (retry,
> abort myapp etc.).
For robustness expect not only the patterns you wait for ( or a matchall