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";}
In reply to A wrapper script for tmpwatch in Linux written in Perl by wishartz
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |