RE: how to interupt a running program

2005-11-30 Thread S, karthik \(IE03x\)

See my comments.


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of zentara
Sent: Monday, November 21, 2005 7:38 PM
To: beginners@perl.org
Subject: Re: how to interupt a running program

On Mon, 21 Nov 2005 10:32:47 +0530, [EMAIL PROTECTED] (karthik S)
wrote:

>I need to control a perl program from another perl program.

>Let me say I have a program one.pl that runs with indefinite loop

> While(1){
>   Print "hello";
> }

>I need another program, Where I shall type in *s* to start one.pl and
>*e* to end the program. The second program shall be a CGI-Perl script.
I
>don't want to *kill* the program but I need to *control* the program
>(one.pl).

>I have to implement this in *Windows XP*. So commands like "fork" and
>similar commands did not help me out..

>Your ideas and code snippets would be a valuable input to me.

First, your over-generous use of newlines make your post hard to read.

You left out some details, like are both programs on the same machine?
[karthik]: yes both the programs run on the same machine.
In any event, it sounds like you need to use Sockets to communicate
between the 2 programs.

In your while(1) loop, you need some server code, to listen on a socket
for your commands. Then the cgi script, accepts some input thru cgi, and
sends it to program1 thru a client connected to the socket.

[karthik]: can we give some samples of code. Let me make it clear.
Forget about cgi. I need the "code to Send a signal from one program"
and "capture that signal in the other program/process".

There are tons of examples on the net for client-server pairs. Go to
http://groups.google.com and search for "perl client server pair".

See
http://www.cs.uno.edu/~golden/teach.html
[karthik]: this does not workout.

for a good explanation of how sockets work. 


My advice, is to do this step-by-step. First setup a client-server pair,
and get it to pass your commands. Once that is done, it will be simple
to get the commands thru CGI and pass them to the socket.

But my question is why have the intermediary CGI step? Why not connect
directly to program1 thru sockets, and control it?

Kind of sounds like a homework question.
[karthik]: sorry, this is not home work. It is a real-time task.


-- 
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Re: how to interupt a running program

2005-11-21 Thread Shawn Corey

S, karthik (IE03x) wrote:

I need to control a perl program from another perl program.


See:
perldoc perlipc (search for "Signals")
perldoc perlvar (search for %SIG)
perldoc -f kill

Also:
perldoc -f fork
perldoc -f wait

The kill function sends a signal to another process, it does not 
necessarily kill it. How the process responds to the signal is its 
business. The only except is the KILL signal (signal number 9) which 
always kills the process. Unfortunately the function to send signals to 
other processes is called kill, which leads to lots of confusion.


--

Just my 0.0002 million dollars worth,
   --- Shawn

"Probability is now one. Any problems that are left are your own."
   SS Heart of Gold, _The Hitchhiker's Guide to the Galaxy_

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




how to interupt a running program

2005-11-20 Thread S, karthik \(IE03x\)
Dear Folks,

   

 

Hear is some interesting task. Please help me out with your ideas.

 

I need to control a perl program from another perl program.

 

Detailed description (example)

#

 

Let me say I have a program one.pl that runs with indefinite loop

 

While(1)

{

Print "hello";

 

}

 

 

I need another program, Where I shall type in *s* to start one.pl and
*e* to end the program. The second program shall be a CGI-Perl script. I
don't want to *kill* the program but I need to *control* the program
(one.pl).

 

I have to implement this in *Windows XP*. So commands like "fork" and
similar commands did not help me out..

 

 

Your ideas and code snippets would be a valuable input to me.

 

With Best Regards, 

Karthikeyan S 
Honeywell Process Solutions - eRetail
Honeywell Automation India Limited 
Phone:91-20-56039400 Extn -2701

Mobile :(0)9325118422
E-Mail: [EMAIL PROTECTED]   

This e-mail, and any attachments thereto, are intended only for use by
the addressee(s) named herein and contain Honeywell confidential
information. If you are not the intended recipient of this e-mail, you
are hereby notified that any dissemination, distribution or copying
which amounts to misappropriation of this e-mail and any attachments
thereto, is strictly prohibited. If you have received this e-mail in
error, please immediately notify me and permanently delete the original
and any copy of any e-mail and any printout thereof.