Solved

Server Proccessing

Posted on 1998-11-26
17
169 Views
Last Modified: 2010-03-04
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
Comment
Question by:faur
  • 6
  • 6
  • 4
  • +1
17 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 1206630
Can you fork off a separate process to open the SMTP session?
0
 

Author Comment

by:faur
ID: 1206631
I don't know what you mean...
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 1206632
if (fork) {
   print "Thank you\n";
} else {
   # do your SMTP things
   exit 0;
}
0
 

Author Comment

by:faur
ID: 1206633
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
 
LVL 51

Expert Comment

by:ahoffmann
ID: 1206634
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
 

Author Comment

by:faur
ID: 1206635
Maybe I wrote it wrong, but it didn't worked for me...
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 1206636
would be nice to see some code or error messages ;-)
0
 
LVL 5

Expert Comment

by:b2pi
ID: 1206637
I agree with ahoffman.  If I could figure this out from here, I'd work for 1-800-PSYCHIC :)
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:faur
ID: 1206638
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
 
LVL 5

Expert Comment

by:b2pi
ID: 1206639
Again, what is the error?  Of course, if you're on Win32, there is no fork.
0
 

Author Comment

by:faur
ID: 1206640
Yes, that's a WIN32 (WindowsNT)
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 1206641
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
 
LVL 5

Accepted Solution

by:
b2pi earned 200 total points
ID: 1206642
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
 
LVL 51

Expert Comment

by:ahoffmann
ID: 1206643
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
 
LVL 5

Expert Comment

by:b2pi
ID: 1206644
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
 
LVL 51

Expert Comment

by:ahoffmann
ID: 1206645
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
 

Author Comment

by:faur
ID: 1206646
Thanks man!
That worked.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Input from stdin for perl 6 118
Perl, group, sort, count question 6 117
PHP equivalent of opening a com object 5 69
Call Shell Script from Perl Script 6 75
Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Edureka is one of the fastest growing and most effective online learning sites.  We are here to help you succeed.

912 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now