So, there's a web client somewhere that sends a request to your apache web server, and to satisfy the request, the web server runs your script, is that it? Did the web client have to perform a login to be able to send that request?

If so, then whatever web application is receiving the request and running your script knows the user-ID for it. You could update your script so that it takes a command-line option, like '--userid=some_username_string', instead of calling getpwuid or whatever to set the name of the user. This way, when the web-app runs your script, it can say who the user is supposed to be. (But when you run it from a command-line shell, and don't provide that option string, it just uses the original method to figure out who you are.)

If the web app does not require a login, then there's no telling who the "user" is. I think the best you can do (if the web app is a perl cgi script) is look at $ENV{REMOTE_ADDR} to get the IP address of the web client.


In reply to Re: Get the currently logged in User name by graff
in thread Get the currently logged in User name by irah

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.