Skip to content

Instantly share code, notes, and snippets.

@typester
Created December 3, 2009 07:11
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save typester/247950 to your computer and use it in GitHub Desktop.
Save typester/247950 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl
use strict;
use warnings;
use FindBin;
use Text::MicroTemplate::File;
my $info = qx{/System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport -I};
my ($ssid) = $info =~ / SSID: (.*)$/m;
my $mt = Text::MicroTemplate::File->new( include_path => [$FindBin::Bin] );
my $hosts;
if (-e "$FindBin::Bin/$ssid.mt" && -f _) {
$hosts = $mt->render_file("$ssid.mt", $ssid);
}
else {
$hosts = $mt->render_file("default.mt");
}
open my $fh, '>', '/etc/hosts' or die $!;
print $fh $hosts;
close $fh;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment