Skip to content

Instantly share code, notes, and snippets.

@CodeBrauer
Created November 9, 2015 10:47
Show Gist options
  • Select an option

  • Save CodeBrauer/ba5352d51ddb836f39ef to your computer and use it in GitHub Desktop.

Select an option

Save CodeBrauer/ba5352d51ddb836f39ef to your computer and use it in GitHub Desktop.
Easy internet-connection checker - If Internet connection works: plays sound
#!/bin/bash
/usr/bin/php /Users/xxx/dev/internetz.php
exit;
# This file can be opened with default Terminal App on Mac OS X
<?php
date_default_timezone_set('Europe/Berlin');
for (;;) {
if (@fsockopen('google.de', 80, $errno, $errstr, 1)) {
shell_exec('osascript -e "set Volume 2"');
for ($i=0; $i < 5; $i++) {
shell_exec('/usr/bin/afplay /Users/xxx/dev/horn.m4a');
}
exit('YAY - INTERNET!');
} else {
echo date('[ d.m.Y H:i:s ] - ') . "Still no internet..." . PHP_EOL;
}
sleep(1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment