wifi script
#!/usr/bin/perl
use strict;
my $eth = ‘eth1′; # here is the interface wich is the wifi device
#the script is executed (under ubuntu) this way:
# sudo ./wifi.pl h1
# parameter denotes determines the network and the key for the script.
my %keys = ( # hardcode all the WEP keys over here
‘h1′ => ‘s:xxxxxxxxxxxx’,
‘h2′ => ‘s:xxxxxxxxxxxx’,
‘h3′ => ‘s:xxxxxxxxxxxx’,
‘h4′ => ‘s:xxxxxxxxxxxx’,
‘o1′ => ‘xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx’,
);
my %net = ( #hardcode all the names of the wifi nets overe here
‘h’ => ‘wf_def’,
‘o’ => ‘dsl’,
);
my %channel = ( #the channels
‘h’ => 6,
‘o’ => 2,
);
chomp (my $key = shift @ARGV);
if ($keys{$key}) {
my $essid = $net{substr($key,0,1)};
!system “iwconfig”, “$eth”, “essid”, $essid or die “iwconfig failed to set essid $!\n”;
print “essid has been set to $essid\n”;
!system “iwconfig”, “$eth”, “key”, “$keys{$key}” or die “iwconfig failed to set key $!\n”;
print “key has been set to $keys{$key}\n”;
my $channel=$channel{substr($key,0,1)};
!system “iwconfig”, “$eth”, “channel”,$channel or die “iwconfig failed to set channel $!\n”;
print “the channel has been set to $channel\n”;
system “dhclient $eth”;
print “dhclient command accomplished successfuly\n”;
} else {
die “There is no such key $key \n”;
}
[...] Ну короче свершилось. Я написал свой первый скриптец. Как это часто случается, не было бы счастья, да несчастье помогло: у меня через пень колоду работал wifi-radar и всякие иные инструментики для перенастройки wifi карты под разные сетки. Я плюнул на них, разобрался как работает iwconfig и быстренько накатал скриптец. Работает зараза! Я почти счастлив. [...]