CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Advanced:
Problems with closing a filehandle work which should run remotely

 



ofornes
New User

Feb 19, 2008, 8:58 AM

Post #1 of 4 (1031 views)
Problems with closing a filehandle work which should run remotely Can't Post

Hi all, this is my first thread here... I have been trying to find solutions through internet but found nothing related to this issue and I finally made a google search for "perl forums" and joined the first one.

I have been programming perl for 3 years, but this is the 1st time I am in need of something like this.

I have a server which sends the post information to a perl CGI script. It digests the data and opens a filehandle to a third party perl program which last like 2 days to finish (it manages a lot of information).

My idea here was to just send the program call, and after, send an e-mail to the user saying "hey, everything was OK and you will receive an e-mail" via sendmail.

The problem is that I have no clue on how to call my program remotely.

My actual code for this is:

open (MODLINK, "-|", $modlink_call) || (&eRROR_webpage and print "<b>Error while bla bla bla" and &eRASE_submitted_files and exit (-1));

while (<MODLINK>)
{
if ($_ eq "ModLink is running...")
{
&nORMAL_webpage;
print "<b>Everything is ok bla bla bla you will be send an e-mail";
close (MODLINK);
exit (-1);
}
}

I don't know if this is the best way, but this is how I have done my servers all my life (remember, only 3 years).

It is supposed to call ModLink.pl , which the first line it returns is "ModLink is running..." and then close both the filehandle first then the connection between the client and the server... but it doesn't... It send the msg saying "<b>Everything is ok... [..]" once the process finishes...

Any insight here?

Thank you in advance.


KevinR
Veteran


Feb 19, 2008, 9:28 AM

Post #2 of 4 (1030 views)
Re: [ofornes] Problems with closing a filehandle work which should run remotely [In reply to] Can't Post

Starting up a long running process via a CGI script is probably not a good way to go about this. Your CGI script will have to wait for all other processes to finish before it finishes. Maybe you can use fork() and start the other program and not have to wait for it to return to end the current program (the CGI script). Check out this link:

http://perldoc.perl.org/perlipc.html#Complete-Dissociation-of-Child-from-Parent

Wait for other replies, or try the perl forums at:

www.perlmonks.com
www.devshed.com
www.tek-tips.com
-------------------------------------------------


ofornes
New User

Feb 19, 2008, 9:51 AM

Post #3 of 4 (1027 views)
Re: [KevinR] Problems with closing a filehandle work which should run remotely [In reply to] Can't Post

Thank you very much, I have just checked the website you post here and it was what I had been looking for... if only I had known that my problem was called "daemonization", I would have come up with the solution faster.


KevinR
Veteran


Feb 19, 2008, 10:29 AM

Post #4 of 4 (1025 views)
Re: [ofornes] Problems with closing a filehandle work which should run remotely [In reply to] Can't Post

You're welcome
-------------------------------------------------

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives