Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Perl-alternative second effort' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Perl-alternative second effort
Authored by: unforeseen:X11 on Mar 15, '04 02:02:35PM
Sorry, that little "<" messed my previous post, so here it is in (hopefully) full length: I like the Idea of the Script, and since I don't know any applescripting and prefer typing some letters to starting an application hidden elsewhere, I wrote a simple Perl-Script to which I aliased 'net', so typing 'net' in the Shell does the same for me. if someone's interested, here's the code.
#!/usr/bin/perl

# checks for network-availability and quits on success

$sleep = 120;             # in seconds
$url = 'http://www.apple.com';

print "testing...";

while(length `curl --connect-timeout 5 --head --silent $url` < 4) {
        ($sec, $min, $hr) = localtime;
        $min =~ s/^(\d{1})$/0\1/;
        $sec =~ s/^(\d{1})$/0\1/;
        print "\rNetwork Connection NOT available @ $hr:$min:$sec \tsleeping ~$sleep seconds | press CTRL-C to abort";
        sleep $sleep;
}

print "\n\a####\nyour Network Connection is up and running.\n####\n";

exit;
bye. unforeseen

[ Reply to This | # ]
Perl-alternative third effort
Authored by: unforeseen:X11 on Mar 15, '04 02:12:14PM
this gives me the creeps, there are some Backslashes missing. Sorry, I didn't use the code-option... line 12:
$min =~ s/^(\d{1})$/0\1/;
line 13:
$sec =~ s/^(\d{1})$/0\1/;
line 14:
print "\rNetwork Connection NOT available @ $hr:$min:$sec \tsleeping ~$sleep seconds | press CTRL-C to abort";
line 18:
print "\n\a####\nyour Network Connection is up and running.\n####\n";


[ Reply to This | # ]