If your page actually _is_ a script, it runs upon opening, i.e. CGI or mod_perl, depending on your Apache setup. You can set it up to run a background job which does whatever, including reading from the Apache environment variables the information you want from the user's system. Once it's launched the background job, you have it print the next HTML page, which has a meta-refresh embedded in it. In the mean time, your background job completes creating its page, and the refresh sends your user to it. That's the long way, to be used only if you have lots of stuff to do. In reality, Perl can do the simple stuff you ask of it so that the dynamic stuff happens between the click and the new page appearing. It's only if you need the pages to stay visible long enough for human eyeballs to read and minds to process that you need to resort to refreshes et al.
Short way:
- User clicks on link http://www.mydomain.org/myperl.cgi
- myperl.cgi reads apache ENV variables,
generates new page,
and displays it - done
or long way:
- User clicks on link myperl.cgi
- myperl.cgi reads Apache ENV variables
- launches background job with system('foo.pl', 'USERIP', '&')
and displays intermediate page with meta-refresh tag to URL of dynamically generated page - bg job does whatever else it needs to do
and generates new page as a file on filesystem - refresh sends user from intermediate page to new page
- done
A caveat is that the referrer and user variables that Apache maintains are often only those of proxies, so you will often get the ip's of AOL proxy machines as opposed to the end-user ip.
Some links:
http://httpd.apache.org/docs/env.html
http://www.apachefreaks.com/apache2/env.html
http://cgi.resourceindex.com/Documentation/Environment_Variables/
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.