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>