bogonspace has asked for the wisdom of the Perl Monks concerning the following question:
perl 5, version 12, subversion 4 (v5.12.4) built for MSWin32-x64-multi-thread Binary build 1205 294981 provided by ActiveState http://www.ActiveState.com Built Jun 20 2011 18:11:54
use warnings; #Read Security Engineering Inventory CSV Export and puke @ failure my $file = 'C:/perl64/seceng.csv'; my $hostpath = 'C:/perl64/nagios/hosts/'; #my $hostpath = '/usr/local/nagios/etc/objects/hosts/'; open (F, $file) || die ("Could not open $file!"); while (<F>) { @fields = split(',', $_); $hostname = $fields[3]; $hostip = $fields[5]; if(-e "$hostip"){ open (HOST, 'C:/perl64/nagios/hosts/' . $hostname) || die "Couldn' +t open: $!"; printf HOST "define host\{"; printf HOST "use linux-server;\n"; printf HOST "host_name $host;\n"; printf HOST "alias $host;\n"; printf HOST "address $hostip;\n"; printf HOST "\}"; } } close F;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Question on loops and variables
by keszler (Priest) on Oct 12, 2011 at 21:42 UTC | |
by bogonspace (Initiate) on Oct 12, 2011 at 21:57 UTC | |
by jethro (Monsignor) on Oct 12, 2011 at 22:32 UTC | |
by AnomalousMonk (Archbishop) on Oct 13, 2011 at 00:06 UTC | |
|
Re: Question on loops and variables
by Marshall (Canon) on Oct 13, 2011 at 05:29 UTC | |
|
Re: Question on loops and variables
by Kc12349 (Monk) on Oct 12, 2011 at 22:10 UTC |