Leser: 2
|< 1 2 3 >| | 21 Einträge, 3 Seiten |
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
#!/usr/bin/perl
#
# Remote-Cmd F.Luettgens
########################
use strict;
use warnings;
use CGI;
use CGI::Carp qw(fatalsToBrowser);
use HTML::Template;
chomp(my $sshbin = `which ssh`);
my $cgi = "/cgi-bin/remotecmd/remotecmd.cgi";
my $goto = $ENV{PATH_INFO};
my $query = CGI->new;
my @configs = $query->param;
my %params = $query->Vars;
$goto =~ s!^/!!;
chomp(my $hostfile = `echo \$WCOLL`); # hostliste auslesen
open(HOSTS, "$hostfile");
my @hostlist = <HOSTS>;
close(HOSTS);
foreach (@hostlist) {
s/i$//; # angehaengtes "i" entfernen
}
print $query->header; # html header schicken
my %map = ( # function-map
output => \&output,
cmd => \&cmd,
exec_cmd => \&exec_cmd,
);
sub cmd {
my $tmpl = HTML::Template->new( filename => 'cmd.tmpl' );
$tmpl->param( SCRIPT => $cgi );
print $tmpl->output;
}
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) {
sshconnect($_, $command);
print ("Output: $_[0]");
}
} else {
ssh_connect($server, $command); # ssh connect
print("Output: $_[0]");
}
}
sub ssh_connect {
my @output = (system("$sshbin $_[0] $_[1]"));
return @output;
}
if( exists $map{$goto} ){
$map{$goto}->();
}
else{
my $tmpl = HTML::Template->new( filename => 'default.tmpl' );
$tmpl->param( SCRIPT => $cgi );
print $tmpl->output;
}
my $output = `befehl`;
my $output = qx{befehl};
1 2 3 4 5 6 7 8 9 10 11
use IPC::Open2; local(*HIS_OUT, *HIS_IN); # Create local handles if needed. $childpid = open2(*HIS_OUT, *HIS_IN, $program, @args) or die "can't open pipe to $program: $!"; print HIS_IN "here's your input\n"; $his_output = <HIS_IN>; close(HIS_OUT); close(README); waitpid($childpid, 0);
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
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 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116
#!/usr/bin/perl # # Remote-Cmd F.Luettgens ######################## use strict; use warnings; use CGI; use CGI::Carp qw(fatalsToBrowser); 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"; print $query->header(); chomp(my $sshbin = `which ssh`); open my $hosts, '<', $hostfile or die "Couldnt open $hostfile: $!"; my @hostlist = <$hosts>; close($hosts); foreach (@hostlist) { s/i$//;   ;   ; # angehaengtes "i" entfernen } my %map = ( exec_cmd => \&exec_cmd, ); my $output = ''; my $options = join "\n", map{ qq~ <option value="$_">$_</option>~ }@hostlist; my $goto = $ENV{PATH_INFO}; $goto =~ s!^/!!; if( exists $map{$goto} ){ $output = $map{$goto}->(\%params); print_output( $output ); } else{ print_html( $options ); } sub exec_cmd { my ($paramref) = @_; my %params = %$paramref; my $server = $params{'hostlist'}; my $command = $params{'command'}; my $send2all = $params{'allhosts'}; my $output = '' if ($send2all eq "send2all") { # ssh connect an alle rechner? foreach (@hostlist) { $output .= ssh_connect($_, $command); } } else { $output = ssh_connect($server, $command); &nbs p; # ssh connect } return $output; } sub ssh_connect { my ($server,$command) = @_; my $output = qx{$sshbin $server $command}; return $output; } sub print_html{ my ($options) = @_; } print <<EOT; <html> <body> <form name="remotecmd" method="post" action="./remotecmd.cgi/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"> $options </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 } sub print_output{ my ($out) = @_; print $out; }
Quote[Wed Jun 13 15:40:23 2007] remotecmd.cgi: syntax error at /usr/local/apache/xadmweb/cgi-bin/remote/remotecmd.cgi line 56, near ") {"
[Wed Jun 13 15:40:23 2007] remotecmd.cgi: syntax error at /usr/local/apache/xadmweb/cgi-bin/remote/remotecmd.cgi line 61, near "}"
[Wed Jun 13 15:40:23 2007] remotecmd.cgi: Execution of /usr/local/apache/xadmweb/cgi-bin/remote/remotecmd.cgi aborted due to compilation errors.
[Wed Jun 13 15:40:23 2007] [error] [client 10.43.26.23] malformed header from script. Bad header=<pre>syntax error at /usr/loca: /usr/local/apache/xadmweb/cgi-bin/remote/remotecmd.cgi
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 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
#!/usr/bin/perl # # Remote-Cmd F.Luettgens ######################## use strict; use warnings; use CGI; use CGI::Carp qw(fatalsToBrowser); 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"; print $query->header(); chomp(my $sshbin = `which ssh`); open my $hosts, '<', $hostfile or die "Couldnt open $hostfile: $!"; my @hostlist = <$hosts>; close($hosts); foreach (@hostlist) { s/i$//;   ;   ; # angehaengtes "i" entfernen } my %map = ( exec_cmd => \&exec_cmd, ); my $output = ''; my $options = join "\n", map{ qq~ <option value="$_">$_</option>~ }@hostlist; my $goto = $ENV{PATH_INFO}; $goto =~ s!^/!!; if( exists $map{$goto} ){ $output = $map{$goto}->(\%params); print_output( $output ); } else{ print_html( $options ); } sub exec_cmd { my ($paramref) = @_; my %params = %$paramref; my $server = $params{'hostlist'}; my $command = $params{'command'}; my $send2all = $params{'allhosts'}; my $output = ''; if ($send2all eq "send2all") { # ssh connect an alle rechner? foreach (@hostlist) { $output .= ssh_connect($_, $command); } } else { $output = ssh_connect($server, $command); &nbs p; # ssh connect } return $output; } sub ssh_connect { my ($server,$command) = @_; my $output = qx{$sshbin $server $command}; return $output; } sub print_html{ my ($options) = @_; print <<EOT; <html> <body> <form name="remotecmd" method="post" action="./remotecmd.cgi/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"> $options </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 } sub print_output{ my ($out) = @_; print $out; }
|< 1 2 3 >| | 21 Einträge, 3 Seiten |