Solved

running some code within a script prior to running next pl

Posted on 1997-12-28
6
150 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
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

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

The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
Ever wondered how to display how many visitors you have online. In this tutorial I will show you an easy but effective way to display the number of online visitors in WhizBase. In this article I assume you have read my previous articles and know …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

867 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

16 Experts available now in Live!

Get 1:1 Help Now