]>
Commit | Line | Data |
---|---|---|
cd1a2927 MT |
1 | #!/usr/bin/perl\r |
2 | #\r | |
3 | # Helper program to get DNS info from dhcpc .info file.\r | |
4 | #\r | |
5 | # (c) Lawrence Manning, 2001\r | |
6 | \r | |
7 | use strict;\r | |
8 | require 'CONFIG_ROOT/general-functions.pl';\r | |
9 | \r | |
10 | my $count = $ARGV[0];\r | |
11 | my ($dhcp, $dns, @alldns, %dhcpc);\r | |
12 | \r | |
13 | if ($count eq "" || $count < 1) {\r | |
14 | die "Bad DNS number given"; }\r | |
15 | \r | |
16 | if (open(FILE, "${General::swroot}/red/iface")) {\r | |
17 | my $iface = <FILE>;\r | |
18 | close FILE;\r | |
19 | chomp ($iface);\r | |
20 | if (!&General::readhash("${General::swroot}/dhcpc/dhcpcd-$iface.info", \%dhcpc)) {\r | |
21 | die "Could not open dhcpc info file";\r | |
22 | }\r | |
23 | } else {\r | |
24 | die "Could not open interface file";\r | |
25 | }\r | |
26 | \r | |
27 | \r | |
28 | $dns = $dhcpc{'DNS'};\r | |
29 | \r | |
30 | @alldns = split(',', $dns);\r | |
31 | \r | |
32 | print "$alldns[$count - 1]\n";\r |