add the save and echo commands
authorminima <minima>
Sun, 6 Jan 2002 17:02:37 +0000 (17:02 +0000)
committerminima <minima>
Sun, 6 Jan 2002 17:02:37 +0000 (17:02 +0000)
Changes
cmd/Commands_en.hlp
cmd/echo.pl [new file with mode: 0644]
cmd/save.pl [new file with mode: 0644]
perl/Messages

diff --git a/Changes b/Changes
index cacc841a586602c4d15b35a7addcc7fb92f746f5..16d685079c60d72bb5c335e4ed646a70f64eba93 100644 (file)
--- a/Changes
+++ b/Changes
@@ -3,7 +3,11 @@
 2. make some mods to allow perl 5.7.2 to run
 3. create $DXProt::eph_restime to allow variable slugging of ephemeral dups
 4. create $DXProt::eph_info_restime to allow a long dupe time for these
-4. create $DXProt::eph_pc34 to allow a short anti dupe slug for rcmd loops
+5. create $DXProt::eph_pc34 to allow a short anti dupe slug for rcmd loops
+6. Add a new sysop cmd 'save' which will save the output of any command (or
+list of commands in "<cmd>") to a file.
+7. Add a new command "echo" which echos its argument to the screen (useful
+for titling in the save command above.
 02Jan02=======================================================================
 1. updated the copyright dates
 2. modernised and extended the Windows instructions a bit.
index 055abd0b9e197cbf1b0b8c6ff10185b99d94243d..5d6dfde5d9abc87e7188f3dad2e43ba6bea62837 100644 (file)
@@ -497,6 +497,39 @@ You can credit someone else by saying:-
 The <freq> is compared against the available bands set up in the 
 cluster.  See SHOW/BANDS for more information.
 
+=== 0^ECHO <line>^Echo the line to the output
+This command is useful in scripts and so forth for printing the
+line that you give to the command to the output. You can use this
+in user_default scripts and the SAVE command for titling and so forth
+
+The script will interpret certain standard "escape" sequences as follows:-
+
+  \t - becomes a TAB character (0x09 in ascii)
+  \a - becomes a BEEP character (0x07 in ascii)
+  \n - prints a new line
+
+So the following example:-
+
+  echo GB7DJK is a dxcluster
+
+produces:-
+
+  GB7DJK is a dxcluster
+
+on the output. You don't need a \n on the end of the line you want to send.
+
+A more complex example:-
+
+  echo GB7DJK\n\tg1tlh\tDirk\n\tg3xvf\tRichard
+
+produces:-
+
+  GB7DJK
+          g1tlh   Dirk
+          g3xvf   Richard
+
+on the output.
+                                      
 === 9^EXPORT <msgno> <filename>^Export a message to a file
 Export a message to a file. This command can only be executed on a local
 console with a fully privileged user. The file produced will be in a form
@@ -1068,6 +1101,37 @@ You can also use all the extra qualifiers such as RR, PRIVATE,
 NOPRIVATE, B that you can use with the SEND command (see SEND
 for further details)
 
+=== 9^SAVE [-d -t -a] <filename> "<cmd>" [...]^Save command output to a file
+This sysop only cammand allows you to save the output of one or more
+commands to a file. For example:-
+
+  save /spider/packclus/dxstats show/dxstat
+
+will save the output of the normal command "show/dxstat" to the file
+"dxstats" in the files area.
+
+You can have some extra flags to the save which will either 
+date stamp or time stamp or both the filename so:-
+
+  save -d /tmp/a <cmd> creates /tmp/a_6-Jan-2002
+  save -t /tmp/a <cmd> creates /tmp/a_2301Z
+  save -d -t /tmp/a <cmd> creates /tmp/a_6-Jan-2002_2301Z
+
+The -a flag means append to the file instead of overwriting it.
+
+You can have more than one command on the line, to do this you MUST
+enclose each command in double quotes (") eg:-
+
+  save /tmp/a "sh/hfstats" "blank +" "sh/vhfstats"
+
+or
+
+  save /tmp/a "sh/hfstats","blank +","sh/vhfstats"
+
+You can only write into places that the cluster has permission for (which
+is that of the "sysop" user [which had BETTER NOT BE "root"]), you will 
+need to create any directories you want to put stuff in beforehand as well.
 === 0^SEND <call> [<call> ...]^Send a message to one or more callsigns
 === 0^SEND RR <call>^Send a message and ask for a read receipt
 === 0^SEND COPY <msgno> <call>^Send a copy of a  message to someone
diff --git a/cmd/echo.pl b/cmd/echo.pl
new file mode 100644 (file)
index 0000000..14497d4
--- /dev/null
@@ -0,0 +1,15 @@
+# 
+# echo the line passed to the output decoding certain 
+# "escape" sequences on the way
+#
+# Copyright (c) 2002 Dirk Koopman G1TLH
+#
+# $Id$
+#
+
+my ($self, $line) = @_;
+
+$line =~ s/\\t/\t/g;                   # tabs
+$line =~ s/\\a/\a/g;                   # beeps
+my @out = split /\\[n]/, $line;
+return (1, @out);
diff --git a/cmd/save.pl b/cmd/save.pl
new file mode 100644 (file)
index 0000000..8d7ece3
--- /dev/null
@@ -0,0 +1,45 @@
+# 
+# save the output of ANY command to a file
+#
+# Copyright (c) 2002 Dirk Koopman G1TLH
+#
+# $Id$
+#
+
+my ($self, $line) = @_;
+return (1, $self->msg('e5')) if $self->priv < 9 || $self->remotecmd;
+
+my ($date_req, $time_req);
+my $app_req = '>';
+if ($line =~ /-d/) {                   # add a date to the end of the filename
+       $line =~ s/\s*-d\s*//;
+       $date_req = 1;
+}
+if ($line =~ /-t/) {                   # add a time to the end of the filename
+       $line =~ s/\s*-t\s*//;
+       $time_req = 1;
+}
+if ($line =~ /-a/) {                   # append to the file
+       $line =~ s/\s*-a\s*//;
+       $app_req = '>>';
+}
+
+my ($fn, $rest) = split /\s+/, $line, 2;
+$fn .= '_' . cldate if $date_req;
+$fn .= '_' . ztime if $time_req;
+$fn =~ s/\s+//g;
+
+my @cmd;
+if ($rest =~ /^\s*\"/) {
+       @cmd = split /\s*\"[\s,]?\"?/, $rest;
+} else {
+       push @cmd, $rest;
+}
+open OF, "$app_req$fn" or return (1, $self->msg('e30', $fn));
+for (@cmd) {
+       print OF map {"$_\n"} $self->run_cmd($_);
+}
+close OF;
+return (1, $self->msg('ok'));
+
+
index 051230bdee0b491f588de4b6814295f4526e06d4..c0f1c06afce5efd1f785cf807f85259f4d2e5450 100644 (file)
@@ -83,6 +83,7 @@ package DXM;
                                e27 => '$_[0] not a numeric or a callsign prefix', 
                                e28 => 'Sorry, you need to be registered (SP $main::myalias to register)',
                                e29 => 'Need a password',
+                               e30 => 'Cannot Open $_[0] $!',
 
                                echoon => 'Echoing enabled',
                                echooff => 'Echoing disabled',