Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 206
  • Last Modified:

Server Proccessing

I have a Perl script that recieves an HTML form input and sends mail.
The problem is that it takes very long time for the Perl script to open a session with the SMTP server. The SMTP server is very slow, so there is nothing to do about that.
Anyway, can I print the output HTML from the script to the client, and the server will wait to open an SMTP session?
I mean, print the "Thank you" reply to the client and the mail send will process on the server, thus the client shouldn't have to wait so long...

Hope for a good one this time.
Thanks.
0
faur
Asked:
faur
  • 6
  • 6
  • 4
  • +1
1 Solution
 
ozoCommented:
Can you fork off a separate process to open the SMTP session?
0
 
faurAuthor Commented:
I don't know what you mean...
0
 
ahoffmannCommented:
if (fork) {
   print "Thank you\n";
} else {
   # do your SMTP things
   exit 0;
}
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
faurAuthor Commented:
Could you explain me what these lines do?
I'm quite new to perl.
Do I need to write this code exactly as you write it?

0
 
ahoffmannCommented:
This program forks, the child and parent part are processed  (somehow) simultaneously.
The child part should do the SMTP session,
while the parent just continues and prints zour "Thank you".
Yes you type the lines as is. Of cause you have to add you special code in the child and parent part.
AFAIK, this will not work for any kind of M$ based systems :-( except XENIX:)
0
 
faurAuthor Commented:
Maybe I wrote it wrong, but it didn't worked for me...
0
 
ahoffmannCommented:
would be nice to see some code or error messages ;-)
0
 
b2piCommented:
I agree with ahoffman.  If I could figure this out from here, I'd work for 1-800-PSYCHIC :)
0
 
faurAuthor Commented:
Ok, guys, cool down there :) here's the lame code:

------------------------------
#!/usr/local/bin/perl

use Net::SMTP;
require "cgi-lib.pl";

&ReadParse(*input);

if (fork) {
    # The "Thank You" screen
    &thanx;
    } else {
        # SMTP stuff
        &send_mail;
        exit 0;
        }
------------------------------

I'm recieving an error on the "if (fork) {" line...
I hope that helps...
0
 
b2piCommented:
Again, what is the error?  Of course, if you're on Win32, there is no fork.
0
 
faurAuthor Commented:
Yes, that's a WIN32 (WindowsNT)
0
 
ahoffmannCommented:
Bad luck: single user, single tasking :-(

Never tested (and can't at the moment), try to use NT's _spawn()
system call. Don't know if you need a libc (comes with any compiler) installed for that.
0
 
b2piCommented:
Not! Not single user, not single tasking.  

Actually, just create a seperate perl script that will handle the SMTP code. call that script, say, DoSMTP.pl (nifty, no?)

Then

use Win32::Process;
use Win32;

my($Process);
Win32::Process::Create($Process,
                                    "C:\\perl.exe", # or whereever
                                    "perl DoSMTP.pl arg1, arg2, etc, manyargs",
                                     0,
                                     NORMAL_PRIORITY_CLASS,
                                     ".")
         || die "CreateProcess Error: ",Win32::FormatMessage(Win32::GetLastError()), " ";

for More info , check perldoc Win32::Process

0
 
ahoffmannCommented:
hey b2pi, nice answer (I was shure that there must be something in perl, just didn't know it; I'm not familar with Win32).
About your example, should it be:
    "perl", "DoSMTP.pl", "arg1", "arg2", "etc", "manyargs",
instead of:
    "perl DoSMTP.pl arg1, arg2, etc, manyargs",
(similar to _spawn() ).

BTW, if there are only 2 possibilities: single- vs. multi-tasking
then NT is single, it's just multi-threaded (it's not my statement, it's just what I can read in M$ descriptions). Anyway, the difference may be theoretically. But NT 4.0 is definitely single user, 'cause there is no possibility to have more than one user full access (login) to the same system.

0
 
b2piCommented:
The code should be as I wrote it.

Further, I can't think of a single metric that would argue that NT is single tasking.  Finally, it is indeed possible to have more than one user have full access to the same system (in a trivial example, yes, Virginia, there is a telnetd daemon)
0
 
ahoffmannCommented:
b2pi, it was just a question: I understand now that the arduments
are  "arg1,"  and  "arg2,"  and so on ..

Further, telnetd ok, then please start notepad :-O
0
 
faurAuthor Commented:
Thanks man!
That worked.
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

  • 6
  • 6
  • 4
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now