Skip to content

Instantly share code, notes, and snippets.

@raymondbutcher
Last active August 29, 2015 14:02
Show Gist options
  • Save raymondbutcher/e27316a6418c361aa565 to your computer and use it in GitHub Desktop.
Save raymondbutcher/e27316a6418c361aa565 to your computer and use it in GitHub Desktop.

Revisions

  1. raymondbutcher revised this gist Jun 9, 2014. 1 changed file with 25 additions and 6 deletions.
    31 changes: 25 additions & 6 deletions waitfor
    Original file line number Diff line number Diff line change
    @@ -1,17 +1,36 @@
    #!/usr/bin/env bash
    #
    # Usage: waitfor <command>
    # Example: waitfor sudo service httpd status
    #
    # Waits until a command returns true (exit code: 0)
    #
    # Save or link this file as "waitwhile" to reverse the check,
    # and wait while the command returns true.
    #

    script=`basename $0`

    if [ -z $1 ]
    then
    script=`basename $0`
    echo "Usage: $script <command>"
    echo "Example: $script sudo service httpd status"
    exit 1
    fi

    until status=`$*`
    do
    echo $status
    sleep 1
    done
    if [ $script == "waitwhile" ]
    then
    while status=`$*`
    do
    echo $status
    sleep 1
    done
    else
    until status=`$*`
    do
    echo $status
    sleep 1
    done
    fi

    echo $status
  2. raymondbutcher created this gist Jun 9, 2014.
    17 changes: 17 additions & 0 deletions waitfor
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    #!/usr/bin/env bash

    if [ -z $1 ]
    then
    script=`basename $0`
    echo "Usage: $script <command>"
    echo "Example: $script sudo service httpd status"
    exit 1
    fi

    until status=`$*`
    do
    echo $status
    sleep 1
    done

    echo $status