Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Host address not getting

by kennethk (Monsignor)
on Sep 26, 2013 at 20:05 UTC ( #1055889=note: print w/ replies, xml ) Need Help??


in reply to Host address not getting

@ARGV is just an array, like any other.

my @address = @ARGV; my @url; for my $i (0 .. @address-1) { $url[$i] = "http://$address[$i]:8161/admi/xml/queues.jsp"; }
where that little bit of code can be written a lot of different ways.
my @address = @ARGV; my @url = map "http://$_:8161/admi/xml/queues.jsp", @address;
A review of For Loops and Foreach Loops in perlsyn might be helpful.

#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.


Comment on Re: Host address not getting
Select or Download Code
Re^2: Host address not getting
by cesargarza (Initiate) on Sep 26, 2013 at 20:56 UTC
    My bad, i think i didn't explain it well. Actually i am working on nagios where i have a group with multiple servers information in the file. Now i have a perl script which basically run and take the information from XML through URL. Instead of i put the hostaddress (http://hostaddress:8161/admin/xml/queues.jsp)as a ARGV, was wondering if perl script take the host address from that file automatically.

      Not familiar with 'nagios', but there certainly shouldn't be any reason Perl can't parse the file and pull the addresses. Can you show us what the file looks like?


      #11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.

      Host address of: http://hostaddress is just not going to "work".
      You need something that will work in a browser.
      Maybe $hostaddress = Google; or something like that.
      Simple "hostaddress" won't work.

      First step is to see the webpage in a browser window before you try to get Perl to do it.

      This "8161" is a port address at a specific web site.

      my ($site) = ARGV; #might work better
      If you ask about a command line parm, then show it in your question.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (16)
As of 2014-10-23 14:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (125 votes), past polls