Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Checking Expect/spawn error status using -open
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  2 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
LisaY  
View profile  
 More options Apr 4 2008, 3:39 pm
Newsgroups: comp.lang.tcl
From: LisaY <lisa...@gmail.com>
Date: Fri, 4 Apr 2008 12:39:09 -0700 (PDT)
Local: Fri, Apr 4 2008 3:39 pm
Subject: Checking Expect/spawn error status using -open
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.).

I'd also be interested in a fuller understanding of the apparent
dichotomy of the footnote and the vertical bar indicating that a
process is actually spawned (which is indeed the case!).

Thanks in advance for any clarifications,
  Lisa


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Uwe Klein  
View profile  
 More options Apr 5 2008, 3:16 pm
Newsgroups: comp.lang.tcl
From: Uwe Klein <uwe_klein_habertw...@t-online.de>
Date: Sat, 05 Apr 2008 21:16:58 +0200
Local: Sat, Apr 5 2008 3:16 pm
Subject: Re: Checking Expect/spawn error status using -open

For robustness expect not only the patterns you wait for ( or a matchall
"default") but handle "timeout" and "eof"
if your expect reaches the "eof" special pattern your process has died.

> I'd also be interested in a fuller understanding of the apparent
> dichotomy of the footnote and the vertical bar indicating that a
> process is actually spawned (which is indeed the case!).

The [spawn] does not create a process.
But your [open "|........"] does.
the ~functional equivalent would be:

        spawn myapp args

the -open option is imho more usefull for talking
to a serial line or similar.
If you have a process hanging on the fd you can
as well spawn this app directly.

uwe


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »