From: Dobrica Pavlinusic Date: Sun, 28 Nov 2010 20:25:22 +0000 (+0000) Subject: create directories for new printers X-Git-Url: http://git.rot13.org/?p=pxelator;a=commitdiff_plain;h=32744ca6e1c741a147f1163afaa4a17e9b468f2d create directories for new printers --- diff --git a/bin/snmp-printer.pl b/bin/snmp-printer.pl index 428f334..8311c44 100755 --- a/bin/snmp-printer.pl +++ b/bin/snmp-printer.pl @@ -6,14 +6,16 @@ use strict; use SNMP::Multi; use Data::Dump qw(dump); +use File::Path; -my $dir = 'json/printer'; +my $dir = 'conf/ip'; use JSON; sub save_json { my ( $path, $json ) = @_; - $path = "$dir/$path"; - open(my $fh, '>', $path); + mkpath "$dir/$path" unless -d "$dir/$path"; + $path = "$dir/$path/snmp-printer.json"; + open(my $fh, '>', $path) || die "$path: $!"; print $fh encode_json $json; close($fh); warn "# $path ", -s $path, " bytes\n"; @@ -22,27 +24,7 @@ sub save_json { my $debug = $ENV{DEBUG} || 0; my $community = 'public'; -my @printers = qw( -10.60.0.20 - -10.60.3.15 -10.60.3.17 - -10.60.3.19 -10.60.3.21 - -10.60.3.23 -10.60.3.25 - -10.60.3.27 -10.60.3.29 - -10.60.3.31 -10.60.3.33 - -10.60.3.35 -10.60.3.37 -); +my @printers = map { s{^conf/ip/([0-9\.]+)/.+$}{$1}; $_ } glob 'conf/ip/*/snmp-printer*'; @printers = @ARGV if @ARGV;