
UnixAAP
Novice
Mar 26, 2014, 12:14 AM
Post #3 of 7
(18858 views)
|
Re: [FishMonger] Help required in refining a script!!!
[In reply to]
|
Can't Post
|
|
Thank you :-) FishMonger,,for the help I used your code .. got below error 1 #!/usr/bin/perl 2 3 use strict; 4 use warnings; 5 use diagnostics; 6 use Net::OpenSSH; 7 8 print "Password: "; 9 system('stty','-echo'); 10 chomp(my $password = <STDIN>); 11 system('stty','echo'); 12 print "\n"; 13 14 open my $fh, '<', 'input.txt' or die "failed to open 'input.txt' <$!>"; 15 16 while (my $host = <$fh>) { 17 chomp $host; 18 if ($host !~ /^\d+\.\d+\.\d+\.\d+$/) { 19 print "$host is not in IPv4 format.\n"; 20 next; 21 } 22 print "Adding files to $host"; 23 $ssh = Net::OpenSSH->new("root:$password\@$host"); 24 $ssh->error and die "Couldn't establish SSH connection: ". $ssh->error; 25 $ssh->system = ("esxcli system syslog config set --loghost='udp://198.19.99.243:514' && esxcli system syslog reload"); ------------------------ # ./test1.pl Global symbol "$ssh" requires explicit package name at ./test1.pl line 23. Global symbol "$ssh" requires explicit package name at ./test1.pl line 24. Global symbol "$ssh" requires explicit package name at ./test1.pl line 24. Global symbol "$ssh" requires explicit package name at ./test1.pl line 25. Missing right curly or square bracket at ./test1.pl line 25, at end of line syntax error at ./test1.pl line 25, at EOF Execution of ./test1.pl aborted due to compilation errors (#1) (F) You've said "use strict" or "use strict vars", which indicates that all variables must either be lexically scoped (using "my" or "state"), declared beforehand using "our", or explicitly qualified to say which package the global variable is in (using "::"). BEGIN not safe after errors--compilation aborted at /usr/share/perl5/Carp/Heavy.pm line 11. Compilation failed in require at /usr/share/perl5/Carp.pm line 33.
   
|