-
Notifications
You must be signed in to change notification settings - Fork 3
/
del_airspace.pl
executable file
·86 lines (70 loc) · 1.51 KB
/
del_airspace.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/usr/bin/perl
require DBD::mysql;
use Airspace qw(:all);
use Math::Trig;
use Data::Dumper;
use POSIX qw(ceil floor);
use strict;
#
# Delete some airspace ..
#
my @airs;
my $sth;
my $dbh;
my $class;
my $listonly = 0;
if ($#ARGV < 1)
{
print "airspace_check [-c airspace class] [-n airspace name]\n";
exit 1;
}
$dbh = db_connect();
while ($#ARGV > 0 and substr($ARGV[0], 0, 1) eq '-')
{
my $ref;
$class = $ARGV[1];
if (substr($ARGV[0], 0, 2) eq '-c')
{
$sth = $dbh->prepare("select * from tblAirspace where airClass like ?");
$sth->execute($class);
while ($ref = $sth->fetchrow_hashref())
{
printf("Delete: %s\n", $ref->{'airName'});
push @airs, $ref->{'airPk'};
}
}
elsif (substr($ARGV[0], 0, 2) eq '-n')
{
$sth = $dbh->prepare("select * from tblAirspace where airName like ?");
$sth->execute($class);
while ($ref = $sth->fetchrow_hashref())
{
printf("Delete: %s\n", $ref->{'airName'});
push @airs, $ref->{'airPk'};
}
}
elsif (substr($ARGV[0], 0, 2) eq '-l')
{
$listonly = 0 + $ARGV[1];
}
else
{
print "airspace_check [-c airspace class] [-n airspace name]\n";
exit 1;
}
shift @ARGV;
shift @ARGV;
}
#$id = $ARGV[0];
#print Dumper(\@airs);
if (scalar @airs == 0)
{
print "Nothing to delete\n";
exit 0;
}
if ($listonly > 0)
{
print "List only\n";
exit 0;
}
delete_airspace($dbh, \@airs);