Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

ntfy already supports sending messages after long running commands:

    ntfy done sleep 10
If you want to also capture output, you can just use a simple bash function:

    ntfy_done_output() {
        local TEMP_FILE="$(mktemp)" SUCCESS LOG
        "${@}" 2>&1 | tee "${TEMP_FILE}"
        SUCCESS="$((!PIPESTATUS[0]))"
        LOG="$(curl -fLX POST -T- <"${TEMP_FILE}" some-pastebin.example.com)"
        if ((SUCCESS)); then
            ntfy send "Success! Log: ${LOG}"
        else
            ntfy send "Failed :(. Log: ${LOG}"
        fi
    }


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: