HowTo tell if from cmd_line || httpd

Discussion in 'Perl Misc' started by ipellew@pipemedia.co.uk, Dec 21, 2004.

  1. Guest

    Hi all;

    Whats a sure fire way to tell I am executed from either httpd or
    command line? At the moment, I decide on HTTP_USER_AGENT having a
    value to say I am from httpd.
    This needs to work whatever the platform / server.

    Regards
    Ian
     
    , Dec 21, 2004
    #1
    1. Advertising

  2. On Tue, Dec 20, inscribed on the eternal
    scroll:

    > Whats a sure fire way to tell I am executed from either httpd or
    > command line?


    You can't, really, since anything you care to test could equally be
    faked from the command line.

    > At the moment, I decide on HTTP_USER_AGENT having a
    > value to say I am from httpd.


    There's no absolute mandate to set that to a non-null value, so I'd
    have to advise against that...

    Seems to me that the closest specified item to what you're
    asking for would be the GATEWAY_INTERFACE :

    http://cgi-spec.golux.com/draft-coar-cgi-v11-03-clean.html#6.1.4

    > This needs to work whatever the platform / server.


    Indeed. If you'd suggested otherwise, you'd have found yourself
    contradicted ;-)

    GATEWAY_INTERFACE -is- a bona fide feature of the CGI specification,
    right from way back: http://hoohoo.ncsa.uiuc.edu/cgi/env.html

    Any so-called CGI interface which fails to provide it would be
    seriously deficient. Of course, it could be faked from the command
    line, as I mentioned before: but anyone who does that gets,
    presumably, just what they asked for.

    --
    Procrastination gives you something to look forward
    to putting off tomorrow. -spotted on ahbou
     
    Alan J. Flavell, Dec 21, 2004
    #2
    1. Advertising

  3. wrote:

    > Hi all;
    >
    > Whats a sure fire way to tell I am executed from either httpd or
    > command line? At the moment, I decide on HTTP_USER_AGENT having a
    > value to say I am from httpd.
    > This needs to work whatever the platform / server.
    >
    > Regards
    > Ian


    You could do that, or use the following (may not work in some platforms):

    sub batch() {
    open(TTY, "/dev/tty");
    return 0 if tcgetpgrp(fileno(*TTY)) == getpgrp();
    return 1;
    }

    sub interactive {
    return !batch();
    }

    gtoomey
     
    Gregory Toomey, Dec 21, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Anders Skar
    Replies:
    3
    Views:
    870
    Anders Skar
    Feb 26, 2004
  2. Ben Jessel
    Replies:
    5
    Views:
    464
    marcus
    Jun 29, 2004
  3. RC
    Replies:
    4
    Views:
    8,020
    Tor Iver Wilhelmsen
    Jul 12, 2005
  4. Matthias Pospiech

    Website is loaded as "application/x-httpd-php"

    Matthias Pospiech, Jun 5, 2005, in forum: HTML
    Replies:
    2
    Views:
    816
    Leif K-Brooks
    Jun 5, 2005
  5. Replies:
    0
    Views:
    377
Loading...

Share This Page