slacktee is a bash script that works like tee command. Instead of writing the standard input to files, slacktee posts it to Slack.

  • Users starred: 751
  • Users forked: 100
  • Users watching: 751
  • Updated at: 2020-05-30 23:02:27


slacktee is a bash script that works like tee command. Instead of writing the standard input to files, slacktee posts it to Slack.



slacktee uses curl command to communicate with Slack.


# Clone git repository
git clone

# Install
bash ./slacktee/ copies in /usr/local/bin and sets executable permission.

If you'd like to install it in the different directory such as /usr/bin, pass the target directory as a parameter of By default, /usr/local/bin may not be included in your $PATH environment variable (you should be aware of this when you use slacktee in crontab). So, if you would like to use slacktee without specifying its full path, coping it to /usr/bin may be a good idea.

# Install in /usr/bin
bash ./slacktee/ /usr/bin

Also, you can rename during the installation. If you would like to give a different name to, simply append it to the target directory.

# Install in /usr/local/bin as 'slacktee'
bash ./slacktee/ /usr/local/bin/slacktee

After the installation, interactive setup starts automatically.


Packages are also availalbe for some platforms:

Scott R. Shinn at Atomicorp created a package of slacktee for following Linux distributions:

  • Centos 6/7
  • RHEL 6/7
  • Amazon Linux 1/2(LTS)
  • Debian 8/9
  • Ubuntu 14/16

These packages are maintained by Atomicorp and their repo can be easily installed to your system through their automated repo installer as following:

wget -q -O - | bash

If you would prefer to download and install the package by yourself, you can find it in their repository page.

It's still alpha version, but we also have a debian package in this github repo.


Before start using slacktee, please set following variables in the script configuration file. slacktee reads the global configuration (/etc/slacktee.conf) first, then reads your local configuration (~/.slacktee). You can set up your local configuration file using interactive setup mode (--setup option).

You would need an authentication token for slacktee. It could be generated in 2 ways:

  1. Crate a Slack App (Preffered by Slack, but a bit complicated to setup)
    Follow steps listed in creating a Slack App.
    Next, create a bot user for your app, give the following 3 permissions to your app: chat:write:bot, files:write:user and bot. More information about the permission scopes can be found at permission scopes.
    At last, install the app to your workplace and get the token in 'OAuth & Permission' feature in the manage application page.
  2. Add a bot (Easy to setup, but Slack may remove it in future)
    Add a bot into your workspace through Slack App Directory. You can now find 'API Token' in the configuration page of the bot.
token=""            # The authentication token of the bot user. Used for accessing Slack APIs.
channel=""          # Default channel to post messages. '#' is prepended, if it doesn't start with '#' or '@'.
tmp_dir="/tmp"      # Temporary file is created in this directory.
username="slacktee" # Default username to post messages.
icon="ghost"        # Default emoji or a direct url to an image to post messages. You don't have to wrap emoji with ':'. See
attachment=""       # Default color of the attachments. If an empty string is specified, the attachments are not used.


Feed input to slacktee through the pipe.

usage: [options]
    -h, --help                        Show this help.
    -n, --no-buffering                Post input values without buffering.
    --streaming                       Post input as it comes in, and update one comment with further input.
    -f, --file                        Post input values as a file.
    -l, --link                        Add a URL link to the message.
    -c, --channel channel_name        Post input values to specified channel or user.
    -u, --username user_name          This username is used for posting.
    -i, --icon emoji_name|url         This icon is used for posting. You can use a word
                                      from or a direct url to an image.
    -t, --title title_string          This title is added to posts.
    -m, --message-formatting format   Switch message formatting (none|link_names|full).
                                      See for more details.
    -p, --plain-text                  Don't surround the post with triple backticks.
    -a, --attachment [color]          Use attachment (richly-formatted message)
                                      Color can be 'good','warning','danger' or any hex color code (eg. #439FE0)
                                      See for more details.
    -e, --field title value           Add a field to the attachment. You can specify this multiple times.
    -s, --short-field title value     Add a short field to the attachment. You can specify this multiple times.
    -o, --cond-color color pattern    Change the attachment color if the specified Regex pattern matches the input.
                                      You can specify this multiple times.
                                      If more than one pattern matches, the latest matched pattern is used.
    -d, --cond-prefix prefix pattern  This prefix is added to the message, if the specified Regex pattern matches the input.
                                      You can specify this multiple times.
                                      If more than one pattern matches, the latest matched pattern is used.
    -q, --no-output                   Don't echo the input.  
    --config config_file              Specify the location of the config file.
    --setup                           Setup slacktee interactively.

If you'd like to post the output of ls command, you can do it like this.

ls |

To post the output of tail -f command line by line, use -n option.

tail -f foobar.log | -n

To post the output of find command as a file, use -f option.

find /var -name "foobar" | -f

You can specify channel, username, icon, title, and link too.

ls | -c "general" -u "slacktee" -i "shipit" -t "ls" -l ""

Instead of emoji icon, you may provide an image url.

ls | -c "general" -u "slacktee" -i "" -t "ls" -l ""

Of course, you can connect another command with pipe.

ls | | email "ls"

Would you like to use richly-formatted message? Use -a, -e and -s options.

cat error.log | -a "danger" -e "Date and Time" "$(date)" -s "Host" "$(hostname)"

Direct message to your teammate 'chuck'? Easy!

echo "Submit Your Expense Reimbursement Form By Friday!" | -c "@chuck"

Conditional coloring and prefix helps you to notice important messages easier. If a specified Regex pattern matches the input, its corresponding color or prefix is used for posting the message. In the example below, the message color is green (good) by default, but the color becomes yellow (warning) if an input log starts with "Warning:". Also, it becomes red (danger) and the prefix @channel is added to the mssage if the log starts with "Error:". It's pretty useful, isn't it?

# To enable @command, '-m link_names' must be specified
tail -f app.log | -n -a "good" -o "warning" "^Warning:" -o "danger" "^Error:" -d "@channel" "^Error:" -m link_names

You can find more examples on Course Hero blog.

Travis-CI Integration

You may want to integrate slacktee into Travis-CI in order to send additional logging information to your Slack channel. In this case, it is recommended that you do not expose your Incoming WebHook URL and API authentication token as plaintext values inside your slacktee.conf file.

Instead, use the encrypt command of the Travis client to set the SLACKTEE_WEBHOOK and SLACKTEE_TOKEN environment variables, and leave the webhook_url and token values in your slacktee.conf empty. When slacktee runs, it will give priority to the environment variables, which Travis-CI will decrypt and set automatically during the build process. In this way those two values are kept secure.


Modify slacktee.conf


Add the encrypted environment variables to the .travis.yml file in your git repository

travis encrypt SLACKTEE_WEBHOOK='' --add
travis encrypt SLACKTEE_TOKEN='yoho-0987654321-1234567890-4488116622-abc123' --add

Looking at your travis.yml you will now see the following added

  - secure: 2YZabH8+UdzqyBWckojRDP9uudnCSYyxOOx1y85el69YdHwLDMD+dt49rAgIrmCWsWCWpUZ0ZRWV8vU2VFMffIhmikiqG7VoKHuN5PyY8qBwr9hq/ZI8gdwgjgfRIGtv/U89BTjMmc1g/6nJkSvMtiSUSK3Lopg0JCyuZsiyhzs=
  - secure: TKpohmywdOneQkqGxJiF+S1N8oCdTWWGsXgjzNXWSvb23KDtvGq/W2SpWdFdwEHC9Y8NymoAPYRSW8MUQoiJ7NaQ1eZQuyx6/orjHpIgqiAuHrOSaMagzpKVG6Gtb87qDgov65ZOasyex1OtPQdfFtZBX67B6IVXkRPV+IA/+UX=

An example travis.yml section using slacktee may look like:

- ls /path/to/build | ./ -t "$TRAVIS_REPO_SLUG $TRAVIS_JOB_NUMBER build directory"
- cat /path/to/some.log | ./ -t "$TRAVIS_REPO_SLUG $TRAVIS_JOB_NUMBER some.log"