Thread SSH Script zur Massenabfrage: kein fehler, kein log, na supi...
(20 answers)
Opened by FlorianL at 2007-06-13 13:26
Guten Morgen! :)
Wieder mal ne ne Frage: Ich lasse mir jetzt die Server zu dennen nicht connected werden kann in einer extra box anzeigen und wollte die aus dem output rausnehmen. Bei nem Array würd ich wohl shift nehmen, aber wie mach ichs denn hier? die exec_cmd sub sieht nun so aus: Code (perl): (dl
)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 sub exec_cmd { my ($paramref) = @_; my %params = %$paramref; my $server = $params{'hostlist'}; my $command = $params{'command'}; my $send2all = $params{'allhosts'}; my $output = ''; if (( $command =~ m/^rm/ ) or ( $command =~ m/^ping/ ) or ( $command =~ m/^login/ ) or ( $command =~ m/^ftp/ ) or ( $command =~ m/^telnet/ ) or ( $command =~ m/^rsh/ )) { die "Command $command ist nicht erlaubt!"; } if ($send2all eq "send2all") { unlink($error); foreach (@hostlist) { chomp; $output .= $_ . "<br />\n" . (ssh_connect($_, $command)); if ((ssh_connect($_, $command)) eq "<br><hr>") { open(ERRORFILE,">>$error") || die "Kann $error nicht oeffnen!"; our $errormsg = '1'; print ERRORFILE ("<font color=\"FF0000\">Warnung:</font> Kann mich nicht auf <b>$_</b> einloggen.<br>\n"); } } } else { chomp $server; $output = $server . '<br />' . ssh_connect($server, $command); } if ($errormsg == '1') { print ("<;script type=\"text/javascript\"> F1 = window.open(\"$error_rel\", \"Fenster1\", \"width=350,height=400,left=0,top=0\"\)\;</script>\n"); close(ERRORFILE); } return $output; unlink($error); } |