#!/usr/bin/perl # # Remote-Cmd F.Luettgens ######################## use strict; use warnings; use CGI; use CGI::Carp qw(fatalsToBrowser); chomp(my $sshbin = `which ssh`); my $cgi = "/cgi-bin/remotecmd/remotecmd.cgi"; my $query = CGI->new; my @configs = $query->param; my %params = $query->Vars; my $hostfile = "/usr/local/etc/rup"; #my $hostfile = ($ENV{WCOLL}); open(HOSTS, "$hostfile") || die "Couldnt open $hostfile: $!"; my @hostlist = ; close(HOSTS); foreach (@hostlist) { s/i$//; # angehaengtes "i" entfernen } my $goto = $ENV{PATH_INFO}; $goto =~ s!^/!!; my %map = ( exec_cmd => \&exec_cmd, ); if( exists $map{$goto} ){ $map{$goto}->(); } sub exec_cmd { my $server = $params{'hostlist'}; my $command = $params{'command'}; my $send2all = $params{'allhosts'}; if ($send2all eq "send2all") { # ssh connect an alle rechner? foreach (@hostlist) { ssh_connect($_, $command); print ("Output: $_[0]"); } } else { ssh_connect($server, $command); # ssh connect print("Output: $_[0]"); } } sub ssh_connect { my @output = qx {$sshbin $_[0] $_[1]}; return @output; } print <
Hostname   Command:
 
Alle Hosts    
 

 

EOT