Solved

Server Proccessing

Posted on 1998-11-26
17
165 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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

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…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
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…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.

757 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

19 Experts available now in Live!

Get 1:1 Help Now