Solved

running some code within a script prior to running next pl

Posted on 1997-12-28
6
152 Views
Last Modified: 2013-12-25
I have written a perl script that retrieves the mail headers of a user. I now want to click on the header to view the message... EASY! but!!! I don't want to re-login to the mail server (which u would have to do if u run a separate perl script when u click on the header)... SO, is there a way you can click on a "link-like" text (ie. text which is underlined so u know when u click on it u will go view your message) but have the current perl script retrieve you mail then and there and then run the next perl script with the data sent to it via POST... thereby defeating the need to relogin to your mail server...??? this question is very difficult to explain so if you are confused tell me where and I will try and clarify that part...
0
Comment
Question by:ramsay
  • 3
  • 3
6 Comments
 
LVL 5

Accepted Solution

by:
icd earned 360 total points
ID: 1831761
The only way to avoid logging onto the mail server again would be to retrieve the mail message at the same time as the header.

For each header retrieved there would be a local file stored which holds the message contents.

When the user clicks on the message header, rather than connect to the mail server it simply retrieves the message content previously stored in the local file store.

To answer this question more specifically then more information would need to be given, such as the details of the script you are using, what server you are running on etc.
0
 
LVL 1

Author Comment

by:ramsay
ID: 1831762
I thought of the same approach.. but it is a poor solution because retrieving the mail headers should just be that. Retreiving the whole message would take considerably longer than just the header especially when you mailbox had quite a few messages too... Hence the solution I am striving towards requires some way I can click on a header.. and before the next page arrives via the next cgi I want to read the mail then and there and then process the link... ***OR*** is there some way I can pass to my next CGI the connection details so in my next cgi I still have the same connection to the server...?? Here are some more details:

POP3 Server.. connected via:

socket(SOCK, &PF_INET, &SOCK_STREAM, $proto);
connect(SOCK, pack($sockaddr, &PF_INET, $port));
select((select(SOCK) , $| = 1)[0]);

... the problem is now when I call my next CGI I lose the connection to my POP3 server and have to connect again... I want to avoid this... and I can only see 2 ways of doing so.. sending some info to the 2nd cgi so it can remain connected to the mail server OR somehow do the processing before I run the next cgi BUT after a header has been selected..


0
 
LVL 5

Expert Comment

by:icd
ID: 1831763
Unfortunately cgi is stateless, although you can pass data from one script to the next you cannot pass file handles. As each script terminates all file handles are closed. Socket connections would be treated in the same way.

The only way I can see to do this is to have a daemon process running in the background which handles the socket connection. Your scripts would then open a pipe to the daemon to, for example, request headers or message bodies. This is not something I have ever done myself so I can't comment on the technicalities.

0
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
LVL 1

Author Comment

by:ramsay
ID: 1831764
cookies? You know anything about them? I hear they could be a solution...?
0
 
LVL 5

Expert Comment

by:icd
ID: 1831765
It does not matter what method you use to pass data from one cgi script to the next, it still applies that file handles and allocated memory, buffers etc will all be freed at the end of a cgi script. You can't pass a file handle from one script to another unless a third process, which remains running, holds it open. I understand that socket connections work in the same way.

Cookies can also be a problem since there seems to be a backlash against their use with some people turning them off or disabling them.
0
 
LVL 1

Author Comment

by:ramsay
ID: 1831766
True... I've decided to use cookies because I actually got it working successfully first try and it didn't cause any problems... Cool! for all those people who may read this in the future go to Matt's archive and download the cookie.lib file! Cookies allow you to communicate between CGIs!!!
Thanx for yer help icd!


0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

In this tutorial I will focus on how to use WhizBase as a tool for sending ICQ messages to ICQ. Here I will use a new technology in WhizBase, published in WhizBase 5.1 version. In this tutorial I will use 3 files, pager.wbsp for the processing, e…
This tutorial will discuss fancy secure registration forms, with AJAX technology support. In this article I assume you already know HTML and some JS. I will write the code using WhizBase Server Pages, so you need to know some basics in WBSP (you mig…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

808 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