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
Dealing with two different exec in tcl
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
  6 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
 
arokia.rajums...@gmail.com  
View profile  
 More options Oct 4 2012, 9:15 am
Newsgroups: comp.lang.tcl
From: arokia.rajums...@gmail.com
Date: Thu, 4 Oct 2012 06:15:51 -0700 (PDT)
Local: Thurs, Oct 4 2012 9:15 am
Subject: Dealing with two different exec in tcl
Hi,

I have a use case to implement something as below,

I started a exec using (eval exec) in a tcl file,
now my use case has to keep checking for that exec to be killed (or) go out of existance at regular interval and do a particular operation after it is killed.

what i see is when i am using "after" call for the periodic timer it is costlier and hanging up my main exec as I am runinning a while look to check for the exec existance.

I am manually searching for the exec from the list of process that are running,as I dont have a system call which will intimate me when that exec is killed.

Please suggest a better way to deal with the above.

Regards,
Raju


 
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.
Arjen Markus  
View profile  
 More options Oct 4 2012, 9:49 am
Newsgroups: comp.lang.tcl
From: Arjen Markus <arjen.markus...@gmail.com>
Date: Thu, 4 Oct 2012 06:49:44 -0700 (PDT)
Local: Thurs, Oct 4 2012 9:49 am
Subject: Re: Dealing with two different exec in tcl
The more idiomatic way to do this is to open a pipe to the program/executable
and monitor its progress via fileevent. There are plenty of examples on the
Wiki of how to do that, but basically:
Whenever the executable writes to standard output or error or terminates,
your Tcl program is notified, that is, the callback procedure you register
with [fileevent] is called. This gives you all the opportunity to check at
regular intervals if it is still there or not.

Regards,

Arjen


 
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.
arokia.rajums...@gmail.com  
View profile  
 More options Oct 5 2012, 2:28 am
Newsgroups: comp.lang.tcl
From: arokia.rajums...@gmail.com
Date: Thu, 4 Oct 2012 23:28:18 -0700 (PDT)
Local: Fri, Oct 5 2012 2:28 am
Subject: Re: Dealing with two different exec in tcl

Hi Arjen,

I did not get what you meant by "open a pipe to the program/executable" can you be more clear on this.

Thanks,
Raju


 
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.
Arjen Markus  
View profile  
 More options Oct 5 2012, 3:50 am
Newsgroups: comp.lang.tcl
From: Arjen Markus <arjen.markus...@gmail.com>
Date: Fri, 5 Oct 2012 00:50:27 -0700 (PDT)
Local: Fri, Oct 5 2012 3:50 am
Subject: Re: Dealing with two different exec in tcl

On Friday, October 5, 2012 8:28:18 AM UTC+2, arokia.r...@gmail.com wrote:
> I did not get what you meant by "open a pipe to the program/executable" can you be more clear on this.

I wanted to avoid writing a code fragment, but here you are:

proc handleInput {infile} {
    if { ![eof $infile] } {
        ... Still alive ... time to close it?
    } else {  
        set ::forever 1
    }

}

set infile [open "|myprogram"]

fileevent $infile readable [list handleInput $infile]

vwait forever

The pipe (the "|" above) establishes a connection between the external program
and your Tcl program. That way you can get the output from the program (and
whether it is at all alive) as it is produced.

Well, this is a sketch, maybe http://wiki.tcl.tk/1757 will help you
further.

Regards,

Arjen


 
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.
arokia.rajums...@gmail.com  
View profile  
 More options Oct 5 2012, 7:08 am
Newsgroups: comp.lang.tcl
From: arokia.rajums...@gmail.com
Date: Fri, 5 Oct 2012 04:08:00 -0700 (PDT)
Subject: Re: Dealing with two different exec in tcl

Hi Arjen,

As I am starting a exec using [eval exec args] which returns me a PID,so in my case open "|[eval exec args]" will only produce a  Tcl Error like : couldn't execute "4112" while executing "open "|[eval exec args]"

Do you have any suggestions on this.

Regards,
Raju


 
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.
Arjen Markus  
View profile  
 More options Oct 5 2012, 8:29 am
Newsgroups: comp.lang.tcl
From: Arjen Markus <arjen.markus...@gmail.com>
Date: Fri, 5 Oct 2012 05:29:58 -0700 (PDT)
Local: Fri, Oct 5 2012 8:29 am
Subject: Re: Dealing with two different exec in tcl

On Friday, October 5, 2012 1:08:00 PM UTC+2, arokia.r...@gmail.com wrote:

> As I am starting a exec using [eval exec args] which returns me a PID,so in my case open "|[eval exec args]" will only produce a  Tcl Error like : couldn't execute "4112" while executing "open "|[eval exec args]"

> Do you have any suggestions on this.

Definitely :) Use:

set infile [open "|$args"]

instead of:

set infile [open "|[eval exec $args]"]

The [open] command will start the program with all the arguments you give
all by itself. It is the pipe sign (|) that instructs it to so.

(With the command you used, you start the program, it returns some data and
that data is then regarded by the [open] command as the name of the file
you want to open.)

Regards,

Arjen


 
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 »