Skip to content

Instantly share code, notes, and snippets.

@jcspencer
Created July 15, 2013 06:39
Show Gist options
  • Save jcspencer/5997904 to your computer and use it in GitHub Desktop.
Save jcspencer/5997904 to your computer and use it in GitHub Desktop.
Check system internet connectivity. Add -m for minimal output. Add these files to your path and run online. :)
#!/bin/bash
node ~/.dotfiles/bin/online.js $@
#!/usr/bin/env node
var colors = require('colors')
var minimal = false;
if(process.argv.indexOf('-m') > -1) {
minimal = true;
}
require('dns').resolve('www.google.com', function(err) {
if(err) {
console.log(minimal ? 'false' : 'You are not connected to the internet!'.red.bold)
} else {
console.log(minimal ? 'true' : 'You are connected to the internet!'.green.bold)
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment