Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Getting Apache Version

by b10m (Vicar)
on Nov 06, 2008 at 08:44 UTC ( #721915=note: print w/ replies, xml ) Need Help??


in reply to Getting Apache Version

I'd probably first scan the machine for apachectl or apache2ctl and when found, launch it with a '-v' flag. That'll show you information like (two random test servers):

$ apachectl -v
Server version: Apache/2.2.4 (FreeBSD)
Server built:   May 18 2008 17:19:41

and

$ apache2ctl -v
Server version: Apache/2.2.3
Server built:   Mar 22 2008 09:29:10

Easy enough to parse that, I assume ;-)

--
b10m


Comment on Re: Getting Apache Version
Re^2: Getting Apache Version
by ultranerds (Pilgrim) on Nov 06, 2008 at 09:23 UTC
    Hi, Thanks for the reply guys. From the sounds of it, there is no "simple" way of doing this. I think the approach I'm gonna take is putting some examples in "comments" inside the script, so they can test the different paths themselves (and if needed, as their host). So something like:
    my $path = 'apachectl'; my $output = `$path -v`; my @split = split /:/, $output; if ($split[1] !~ /\d\.\d\.\d/) { print qq|Cant find Apache version <br />|; } else { print qq|$split[1] <br />|; }
    Thanks guys. Andy
Re^2: Getting Apache Version
by ultranerds (Pilgrim) on Nov 06, 2008 at 09:59 UTC
    Damn it - won't work :(
    #!/usr/bin/perl # example paths can be: # apachectl # apache2ctl # httpd my $path = 'httpd'; print "Content-Type: text/html \n\n"; print "Perl: " . $] . "<br />"; my $output = `$path -v`; my $output2 = system(qq|$path -v|); print "OUTPUT: ($path -v) " . $output . "<br />"; print "OUTPUT 2: ($path -v, as system()) " . $output2 . "<br />"; my @split = split /:/, $output; if ($split[1] !~ /\d\.\d\.\d/) { print qq|Cant find Apache version <br />|; } else { print qq|$split[1] <br />|; }
    ..yet all that gives is:
    Perl: 5.008004 OUTPUT: (httpd -v) OUTPUT 2: (httpd -v, as system()) -1 Cant find Apache version
    Seems that it doesn't like giving the results with `` or system(). Any suggestions? TIA Andy
      Anyone got any suggestions? :/

      Cheers

      Andy
        I don't see where you check error messages, or check that httpd is in the path and readable and executable by current user

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://721915]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (9)
As of 2014-09-17 07:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (64 votes), past polls