wishartz has asked for the wisdom of the Perl Monks concerning the following question:
I think the data structure that I've used needs to be changed, because the host name is a key rather than a value. I just don't know how to do it. Any help is appreciated. Thanks.use warnings; use vars qw( $choicesystem $choicehours $option $manager $host %hours $hourkey $row ); $host = `hostname`; our %filesystem = ( 1 => { name => "/filesystema", host => { namehost1 => 1 }, }, 2 => { name => "/filesystemb", host => { namehost2=> 2 }, }, 3 => { name => "/filesystemc", host => { namehost3 => 3 }, }, ); %hours=(1=>"48",2=>"96"); #print Dumper(%filesystem); debug chomp($host); print "$host\n"; print "----------------Menu-----------------------------------------\n +"; print "Please choose from the list of file systems\n"; print "-------------------------------------------------------------\n +"; for $row (sort keys %filesystem){ my $system=$filesystem{$row}; print "$row\t $system->{ name }\n"; } print "Please enter number>"; chomp($choicesystem = <STDIN>); my $system = $filesystem{ $choicesystem }; print "----------------Menu-----------------------------------------\n +"; print "Please choose the number of hours\n"; print "-------------------------------------------------------------\n +"; foreach $hourkey (keys %hours){ print "$hourkey\t $hours{$hourkey} \n" } print "Please enter number>"; chomp($choicehours = <STDIN>); my $choicehours = $hours{$choicehours}; if ( not $system->{host}{$host}){ system "/usr/bin/ssh $system->{host}#this part doesn't work, o +nly brings back reference"; print "/usr/bin/sudo /usr/sbin/tmpwatch - +f $choicehours $system->{name}\n"; } else { print "/usr/bin/sudo /usr/sbin/tmpwatch -f $choicehours $system +->{name}\n";}
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: A wrapper script for tmpwatch in Linux written in Perl
by bloonix (Monk) on Jul 03, 2007 at 11:18 UTC | |
by wishartz (Beadle) on Jul 03, 2007 at 12:14 UTC | |
|
Re: A wrapper script for tmpwatch in Linux written in Perl
by john_oshea (Priest) on Jul 03, 2007 at 12:22 UTC | |
by wishartz (Beadle) on Jul 03, 2007 at 12:43 UTC | |
by wishartz (Beadle) on Jul 03, 2007 at 14:07 UTC |