2 # module to do startup script handling
4 # Copyright (c) 2001 Dirk Koopman G1TLH
20 my $base = "$main::root/scripts";
25 $s =~ s/([-\w\d_]+)/$1/g;
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}};
121 my $call = clean($self->{call});
126 $try = "$base/" . clean(lc $self->call);
130 $try = "$base/" . clean(uc $self->call);
137 unless (unlink $fn) {
138 return ($self->msg('m22'. $call));
140 return ($self->msg('m20', $call));
142 return ($self->msg('e3', "unset/startup", $call));