2 # module to do startup script handling
4 # Copyright (c) 2001 Dirk Koopman G1TLH
20 my $base = "$main::root/scripts";
32 my $script = clean(shift);
33 my $mybase = shift || $base;
34 my $fn = "$mybase/$script";
36 my $self = {call => $script};
37 my $fh = IO::File->new($fn);
41 $fh = IO::File->new(lc $fn);
54 $self->{lines} = \@lines;
55 $self->{inscript} = 1;
56 return bless $self, $pkg;
63 my $return_output = shift;
66 foreach my $l (@{$self->{lines}}) {
67 unless ($l =~ /^\s*\#/ || $l =~ /^\s*$/) {
68 $dxchan->inscript(1) if $self->{inscript};
69 push @out, DXCommandmode::run_cmd($dxchan, $l);
70 $dxchan->inscript(0) if $self->{inscript};
71 last if @out && $l =~ /^pri?v?/i;
77 if ($dxchan->can('send_ans')) {
78 $dxchan->send_ans(@out);
89 $self->{inscript} = shift if @_;
90 return $self->{inscript};
95 my $call = clean(lc shift);
97 my $ref = ref $_[0] ? shift : \@_;
99 my $fn = "$base/$call";
101 rename $fn, "$fn.o" if -e $fn;
102 my $f = IO::File->new(">$fn") || return undef;
108 unlink $fn unless $count;
115 return @{$self->{lines}};