2 # module to do startup script handling
4 # Copyright (c) 2001 Dirk Koopman G1TLH
20 use vars qw($VERSION $BRANCH);
21 $VERSION = sprintf( "%d.%03d", q$Revision$ =~ /(\d+)\.(\d+)/ );
22 $BRANCH = sprintf( "%d.%03d", q$Revision$ =~ /\d+\.\d+\.(\d+)\.(\d+)/ || (0,0));
23 $main::build += $VERSION;
24 $main::branch += $BRANCH;
26 my $base = "$main::root/scripts";
38 my $script = clean(shift);
39 my $mybase = shift || $base;
40 my $fn = "$mybase/$script";
42 my $self = {call => $script};
43 my $fh = IO::File->new($fn);
47 $fh = IO::File->new(lc $fn);
60 $self->{lines} = \@lines;
61 $self->{inscript} = 1;
62 return bless $self, $pkg;
69 my $return_output = shift;
72 foreach my $l (@{$self->{lines}}) {
73 unless ($l =~ /^\s*\#/ || $l =~ /^\s*$/) {
74 $dxchan->inscript(1) if $self->{inscript};
75 push @out, DXCommandmode::run_cmd($dxchan, $l);
76 $dxchan->inscript(0) if $self->{inscript};
77 last if @out && $l =~ /^pri?v?/i;
83 if ($dxchan->can('send_ans')) {
84 $dxchan->send_ans(@out);
95 $self->{inscript} = shift if @_;
96 return $self->{inscript};
101 my $call = clean(lc shift);
103 my $ref = ref $_[0] ? shift : \@_;
105 my $fn = "$base/$call";
107 rename $fn, "$fn.o" if -e $fn;
108 my $f = IO::File->new(">$fn") || return undef;
114 unlink $fn unless $count;
121 return @{$self->{lines}};