1
0
mirror of https://github.com/Luzifer/waitfor.git synced 2024-07-21 11:46:56 +00:00
Utility to check the exit code of an command to be used within a shell command
Go to file
2018-10-18 23:28:38 +02:00
vendor Vendor dependencies 2018-10-18 23:25:09 +02:00
.gitignore Initial version 2018-10-18 23:19:20 +02:00
.repo-runner.yaml Add auto-build 2018-10-18 23:22:17 +02:00
Gopkg.lock Vendor dependencies 2018-10-18 23:25:09 +02:00
Gopkg.toml Vendor dependencies 2018-10-18 23:25:09 +02:00
History.md prepare release v0.1.0 2018-10-18 23:28:38 +02:00
LICENSE Initial version 2018-10-18 23:19:20 +02:00
main.go Fix: Ensure cancel is called 2018-10-18 23:26:58 +02:00
Makefile Add auto-build 2018-10-18 23:22:17 +02:00
README.md Initial version 2018-10-18 23:19:20 +02:00

Go Report Card

Luzifer / waitfor

waitfor is a small utility to check the exit code of an command to be used within a shell command.

Usage

$ waitfor --help
Usage of waitfor:
  -i, --check-interval duration    How long to wait after an unsuccessful check (default 1s)
  -c, --command-timeout duration   Stop the command execution after this time
      --log-level string           Log level (debug, info, warn, error, fatal) (default "info")
  -s, --shell string               Shell to execute with the given command (must accept -c flag) (default "/bin/bash")
      --version                    Prints current version and exits
  -w, --wait-timeout duration      Stop waiting for the command after this time

When a wait-timeout is specified and the check command did not exit with status code 0 before the timeout is reached waitfor will exit with status 1. This ensures a shell command connected with && is not executed afterwards.

Examples

  • Wait for the VPN connection to be available before executing a command using it

    $ waitfor 'ip a | grep 10.123.0' && echo "VPN connected"
    
  • Ensure you are online before executing a curl command

    $ waitfor -- ping -c 1 8.8.8.8 && curl ...
    
  • Wait at most 5m for a file to appear before accessing it

    $ waitfor -w 5m -- ls myfile && cat myfile