|
comp.lang.perl.misc - PERL programming language
|
|
If you were Registered and logged in, you could reply and use other advanced thread options
|
Posted by ipellew on December 20, 2004, 5:05 pm
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
|
|
Posted by Alan J. Flavell on December 21, 2004, 4:13 am
On Tue, Dec 20, ipellew@pipemedia.co.uk 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
|
|
Posted by Gregory Toomey on December 21, 2004, 1:46 pm
ipellew@pipemedia.co.uk 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
|
This Thread
If you were Registered and logged in, you could reply and use other advanced thread options
Related Posts
Latest Posts
|
|
> command line?