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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/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 = <HOSTS>;
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 <<EOT; # Start des ekligen dreamweaver codes
Content-Type: text/html
<html>
<body>
<form name="remotecmd" method="post" action="./remotecmd.cgi?goto=exec_cmd">
<table width="812" border="0" align="center">
<tr>
<td width="94">Hostname</td>
<td width="86"> </td>
<td width="610">Command:</td>
</tr>
<tr>
<td><select name="hostlist" id="hostlist">
EOT
foreach (@hostlist) {
chomp;
print (" <option value=\"$_\">$_</option>\n");
}
print <<EOT;
</select></td>
<td> </td>
<td><input name="command" type="text" id="command" value="uname -a" size="70"></td>
</tr>
<tr>
<td><input type="radio" name="allhosts" value="send2all">Alle Hosts </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td><input type="submit" name="Submit" value="Absenden"></td>
<td><input name="cancel" type="reset" id="cancel" value="Zurücksetzen"></td>
<td> </td>
</tr>
</table>
<p> </p>
</form>
</body>
</html>
EOT
ich weiss das das so nicht funktioniert, hast du mir ja letztes mal schon erklärt und dann auf html::template hingewiesen.. wie das modul funktioniert hab ich soweit halbwegs verstanden und konnte auch damit arbeiten...
jetzt haben die mich hier beschnitten und es mir wieder entrissen :(
ich glaube ich hätte es einfacher wenn ich das script zweiteile und vom forumlar aus aufs "save-script" linke, aber dann müsst ich wiederrum die vars die von beiden scripts benutzt werden in eine 3. datei schreiben und includen.. das erscheint bei näherer betrachtung doch nicht mehr so sinnvoll...
hint anyone? :)