Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > HowTo tell if from cmd_line || httpd

Reply
Thread Tools

HowTo tell if from cmd_line || httpd

 
 
ipellew@pipemedia.co.uk
Guest
Posts: n/a
 
      12-21-2004
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

 
Reply With Quote
 
 
 
 
Alan J. Flavell
Guest
Posts: n/a
 
      12-21-2004
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...ean.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
 
Reply With Quote
 
 
 
 
Gregory Toomey
Guest
Posts: n/a
 
      12-21-2004
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to get all httpd environment variables in JSP/Servlet? RC Java 4 07-12-2005 08:32 PM
Website is loaded as "application/x-httpd-php" Matthias Pospiech HTML 2 06-05-2005 07:07 PM
Re: {Virus?} Mail Delivery (failure httpd@ncsa.uiuc.edu) httpd@ncsa.uiuc.edu Python 0 09-09-2004 06:53 AM
Re: Configure Apache HTTPD not to see the webapp name in the URL Ben Jessel Java 5 06-29-2004 02:59 AM
Apache HTTPD + Tomcat and random missing images Anders Skar Java 3 02-26-2004 04:25 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57