Solved

Server Proccessing

Posted on 1998-11-26
17
189 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: 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!

 

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
 

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

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
PERL get the value for query 4 162
Perl for loop for 2000 ms 7 112
Removing file extension within a file. 4 112
pipe to sed or perl, please help 5 143
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…
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
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…

734 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