projects
/
spider.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add Local::ann() as requested by Felipe PY1NB.
[spider.git]
/
perl
/
Script.pm
diff --git
a/perl/Script.pm
b/perl/Script.pm
index 8fdd806496c34df3c684abad02b98b46326fb6d7..716ee46e84d1f9655d02a5659609b79aeeb55685 100644
(file)
--- a/
perl/Script.pm
+++ b/
perl/Script.pm
@@
-3,7
+3,7
@@
#
# Copyright (c) 2001 Dirk Koopman G1TLH
#
#
# Copyright (c) 2001 Dirk Koopman G1TLH
#
-#
$Id$
+#
#
package Script;
#
package Script;
@@
-17,12
+17,6
@@
use DXCommandmode;
use DXVars;
use IO::File;
use DXVars;
use IO::File;
-use vars qw($VERSION $BRANCH);
-$VERSION = sprintf( "%d.%03d", q$Revision$ =~ /(\d+)\.(\d+)/ );
-$BRANCH = sprintf( "%d.%03d", q$Revision$ =~ /\d+\.\d+\.(\d+)\.(\d+)/ || (0,0));
-$main::build += $VERSION;
-$main::branch += $BRANCH;
-
my $base = "$main::root/scripts";
sub clean
my $base = "$main::root/scripts";
sub clean
@@
-35,12
+29,22
@@
sub clean
sub new
{
my $pkg = shift;
sub new
{
my $pkg = shift;
- my $script = clean(lc shift);
- my $fn = "$base/$script";
+ my $script = clean(shift);
+ my $mybase = shift || $base;
+ my $fn = "$mybase/$script";
- my $fh = new IO::File $fn;
- return undef unless $fh;
- my $self = bless {call => $script}, $pkg;
+ my $self = {call => $script};
+ my $fh = IO::File->new($fn);
+ if ($fh) {
+ $self->{fn} = $fn;
+ } else {
+ $fh = IO::File->new(lc $fn);
+ if ($fh) {
+ $self->{fn} = $fn;
+ } else {
+ return undef;
+ }
+ }
my @lines;
while (<$fh>) {
chomp;
my @lines;
while (<$fh>) {
chomp;
@@
-48,6
+52,7
@@
sub new
}
$fh->close;
$self->{lines} = \@lines;
}
$fh->close;
$self->{lines} = \@lines;
+ $self->{inscript} = 1;
return bless $self, $pkg;
}
return bless $self, $pkg;
}
@@
-55,17
+60,34
@@
sub run
{
my $self = shift;
my $dxchan = shift;
{
my $self = shift;
my $dxchan = shift;
+ my $return_output = shift;
+ my @out;
+
foreach my $l (@{$self->{lines}}) {
unless ($l =~ /^\s*\#/ || $l =~ /^\s*$/) {
foreach my $l (@{$self->{lines}}) {
unless ($l =~ /^\s*\#/ || $l =~ /^\s*$/) {
- my @out = DXCommandmode::run_cmd($dxchan, $l);
- if ($dxchan->can('send_ans')) {
- $dxchan->send_ans(@out);
- } else {
- dbg($_) for @out;
- }
+ $dxchan->inscript(1) if $self->{inscript};
+ push @out, DXCommandmode::run_cmd($dxchan, $l);
+ $dxchan->inscript(0) if $self->{inscript};
last if @out && $l =~ /^pri?v?/i;
}
}
last if @out && $l =~ /^pri?v?/i;
}
}
+ if ($return_output) {
+ return @out;
+ } else {
+ if ($dxchan->can('send_ans')) {
+ $dxchan->send_ans(@out);
+ } else {
+ dbg($_) for @out;
+ }
+ }
+ return ();
+}
+
+sub inscript
+{
+ my $self = shift;
+ $self->{inscript} = shift if @_;
+ return $self->{inscript};
}
sub store
}
sub store
@@
-95,7
+117,6
@@
sub lines
sub erase
{
sub erase
{
- my $call = clean(lc shift);
- my $fn = "$base/$call";
- unlink $fn;
+ my $self = shift;
+ unlink $self->{fn};
}
}