Solved

running some code within a script prior to running next pl

Posted on 1997-12-28
6
149 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 1

Author Comment

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

Expert Comment

by:icd
Comment Utility
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
Comment Utility
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

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!

Join & Write a Comment

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…
It is a general practice to get rid of old user profiles on a computer  in a LAN environment. As I have been working with a company in a LAN environment where users move from one place to some other place at times. This will make many user profil…
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
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…

744 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

8 Experts available now in Live!

Get 1:1 Help Now