Command Line Polling

By  on  

In an ideal world, we wouldn't have to poll for anything; we would always have events to trigger other functions.  This isn't an ideal world, however, so it's important to know how to poll in multiple programming languages.  I've covered JavaScript polling (with and without Promises), but what about command line polling?  For example, ensuring MYSQL is up before attempting to perform more operations.

Here's the basic syntax:

# while ! (command here); do
while ! mysql -uroot; do
  sleep 1
done

The example above performs the mysql -uroot operation (which will fail until mysqld is up) every second.  Keep in mind the poll operation you run should be as simple as possible, just enough to know that what you want to use is available!

Recent Features

Incredible Demos

  • By
    jQuery Countdown Plugin

    You've probably been to sites like RapidShare and MegaUpload that allow you to download files but make you wait a specified number of seconds before giving you the download link. I've created a similar script but my script allows you to animate the CSS font-size...

  • By
    Create a Dojo Lightbox with dojox.image.Lightbox

    One of the reasons I love the Dojo Toolkit is that it seems to have everything.  No scouring for a plugin from this site and then another plugin from that site to build my application.  Buried within the expansive dojox namespace of Dojo is

Discussion