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

Re: Host address not getting

by kennethk (Abbot)
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.

Replies are listed 'Best First'.
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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1055889]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2018-05-23 05:24 GMT
Find Nodes?
    Voting Booth?