Aller au contenu

CLI Tips

Ce contenu n’est pas encore disponible dans votre langue.

This page contains some tips and helpful information when working with the Apprise Command Line Interface (CLI).

Scripting Multi-Line Input/Output with CLI

Section titled “Scripting Multi-Line Input/Output with CLI”

If you’re using the apprise tool from the command line, you may be trying to script it to send multiple lines. To acomplish this, there are a number of tweaks you can do with bash, sh, or ksh such as: Those who want to deliver multiple line output can use the CLI as follows:

Terminal window
# Send ourselves a DBus related multi-line notification using `stdin` and
# the `cat` tool:
cat << _EOF | apprise -vv -t "Multi-line STDIN Redirect Example" dbus://
Line 1 of output
Line 2 of output
Line 3 of output
_EOF

Another way is to just redirect the contents of file straight back into Apprise:

Terminal window
cat ~/notes.txt | apprise -vv -t "Multi-line cat STDIN Redirect Example 2" \
"email://user:pass@hotmail.com"

You can also use pass content from a multi-line variable you declared:

Terminal window
MULTILINE_VAR="
This variable has been defined
with multiple lines in it."
# Now send our variable straight into apprise:
apprise -vv -t "Multi-line Variable Example" -b "$MULTILINE_VAR" \
"gotify://localhost"
# Note: to preserve the new lines, be sure to wrap your
# variable in quotes (like example does above).

Users of Tmux can link their alert-bell to use Apprise like so:

Terminal window
# set your tmux bell-action to type 'other':
set-option -g bell-action other
# now set tmux to trigger on `alert-bell` actions
set-hook -g alert-bell 'run-shell "\
apprise \
--title \"tmux finished on #{host}\" \
--body \"in session #{session_name} window #{window_index}:#{window_name}\" \
discord://webhook_id/webhook_token \
slack://TokenA/TokenB/TokenC/Channel \
twilio://AccountSid:AuthToken@FromPhoneNo"