Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

running some code within a script prior to running next pl

Posted on 1997-12-28
6
Medium Priority
?
159 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
[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
  • 3
  • 3
6 Comments
 
LVL 5

Accepted Solution

by:
icd earned 1440 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
Learn by Doing. Anytime. Anywhere.

Do you like to learn by doing?
Our labs and exercises give you the chance to do just that: Learn by performing actions on real environments.

Hands-on, scenario-based labs give you experience on real environments provided by us so you don't have to worry about breaking anything.

 
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

Docker-Compose to Simplify Multi-Container Builds

Our veteran DevOps Author takes you through how to build a multi-container environment, managed with a single utility in order to simplify your deployments.

Question has a verified solution.

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

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…
In this tutorial I will show you how to make a simple HTML bar chart with the usage of WhizBase, If you want more information about WhizBase please read my previous articles at http://www.experts-exchange.com/ARTH_5123186.html (http://www.experts-ex…
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.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

719 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