1
|
--- /usr/bin/moncmd Thu Sep 6 13:46:26 2001
|
2
|
+++ /webmin-0.87/mon/moncmd.pl Mon Sep 10 13:40:37 2001
|
3
|
@@ -2,6 +2,8 @@
|
4
|
#
|
5
|
# moncmd - send a command to the mon server
|
6
|
#
|
7
|
+# original file is modified to suit for the operation in this webmin module of msclinux--dt 09 Sept 2001
|
8
|
+#
|
9
|
# Jim Trocki, trockij@transmeta.com
|
10
|
#
|
11
|
# $Id: moncmd 1.2 Fri, 12 Jan 2001 08:13:31 -0800 trockij $
|
12
|
@@ -53,10 +55,12 @@
|
13
|
if ($opt_f) {
|
14
|
if ($opt_f eq "-") {
|
15
|
$H = STDIN;
|
16
|
+#print LOG "READING H from STDIN<br>";
|
17
|
} else {
|
18
|
open (IN, $opt_f) ||
|
19
|
die "could not open input file: $!\n";
|
20
|
$H = IN;
|
21
|
+#print LOG "READING H from IN<br>";
|
22
|
}
|
23
|
|
24
|
} elsif (!@ARGV) {
|
25
|
@@ -77,14 +81,18 @@
|
26
|
# get auth info
|
27
|
#
|
28
|
if ($opt_a) {
|
29
|
+#open (LOG,">/tmp/monlog");
|
30
|
if ($opt_l) {
|
31
|
$USER = $opt_l;
|
32
|
+#print LOG "USER READ FROM -l OPTION =$USER\n";
|
33
|
} else {
|
34
|
die "could not determine username\n"
|
35
|
unless defined ($USER = getpwuid($EUID));
|
36
|
+#print LOG "USER DEFAULT TAKEN=$USER\n";
|
37
|
}
|
38
|
|
39
|
if (-t STDIN) {
|
40
|
+#print LOG "READING PASSWD FROM STDIN\n";
|
41
|
system "stty -echo";
|
42
|
print "Password: ";
|
43
|
chop ($PASS = <STDIN>);
|
44
|
@@ -94,19 +102,27 @@
|
45
|
|
46
|
} elsif (!@ARGV) {
|
47
|
$cmd = <$H>;
|
48
|
+#print LOG "READING CMD FROM $H\n";
|
49
|
+#print LOG "CMD:$cmd\n";
|
50
|
while (defined ($cmd) && $cmd =~ /user=|pass=/i) {
|
51
|
+ #while (defined ($cmd) && $cmd =~ /user|pass/i) {
|
52
|
chomp $cmd;
|
53
|
+#print LOG "CMD AFTER CHOMP:$cmd\n";
|
54
|
if ($cmd =~ /^user=(\S+)$/i) {
|
55
|
$USER=$1 if (!defined ($USER));
|
56
|
+#print LOG "READING USER FROM $H:$USER\n";
|
57
|
} elsif ($cmd =~ /^pass=(\S+)$/i) {
|
58
|
$PASS=$1;
|
59
|
+#print LOG "READING PASSWD FROM $H:$PASS\n";
|
60
|
}
|
61
|
|
62
|
$cmd = <$H>;
|
63
|
+ $cmd1=$cmd;
|
64
|
+#print LOG "FINAL CMD: $cmd\n";
|
65
|
}
|
66
|
|
67
|
}
|
68
|
-
|
69
|
+
|
70
|
die "inadequate authentication information supplied\n"
|
71
|
if ($USER eq "" || $PASS eq "");
|
72
|
}
|
73
|
@@ -148,13 +164,16 @@
|
74
|
|
75
|
|
76
|
if ($opt_f or !@ARGV) {
|
77
|
- $cmd = <$H> if ($opt_f || !@ARGV);
|
78
|
+ #$cmd = <$H> if ($opt_f || !@ARGV);
|
79
|
+ $cmd = (<$H>||$cmd1) if ($opt_f || !@ARGV);
|
80
|
$l = "";
|
81
|
+#print LOG "ENTERING TO SEND THE CMD:$cmd\n";
|
82
|
while (defined ($cmd) && defined ($l)) {
|
83
|
#
|
84
|
# send the command
|
85
|
#
|
86
|
chomp $cmd;
|
87
|
+#print LOG "SENDING THE CMD:$cmd\n";
|
88
|
($l, @out) = do_cmd (MON, $cmd);
|
89
|
last if (!defined ($l));
|
90
|
for (@out) {
|
91
|
@@ -181,6 +200,7 @@
|
92
|
|
93
|
close(MON);
|
94
|
|
95
|
+#close(LOG);
|
96
|
|
97
|
#
|
98
|
# submit a command to the server, wait for a response
|
99
|
@@ -193,6 +213,7 @@
|
100
|
|
101
|
@out = ();
|
102
|
print $fd "$cmd\n";
|
103
|
+#print LOG "SUBMITTING CMD:$cmd\n";
|
104
|
while (defined($l = <$fd>)) {
|
105
|
chomp $l;
|
106
|
if ($l =~ /^(\d{3}\s)/) {
|