Environment variables

All arguments are also passed as environment variables as well, which can be very useful when passing several arguments to a script, for example.

config.yaml
actions:
  - title: Print names of new files
    shell: /opt/newfile.py
    arguments:
      - name: filename
        type: unicode_identifier

      - name: filesizebytes
        type: unicode_identifier

      - name: fileisdir
        type: unicode_identifier

    execOnFileCreatedInDir:
      - /home/user/Downloads/

This is an example of a python script using the environment variables;

/opt/newfile.py
#!/usr/bin/env python

import os

print(os.environ['OLIVETIN'])
print(os.environ['FILENAME'])
print(os.environ['FILESIZEBYTES'])
print(os.environ['FILEISDIR'])

Notes

  1. Argument names are converted to uppercase for environment variables, name: filename becomes FILENAME.

  2. OliveTin also passes an environment variable called OLIVETIN which is always just set to 1, which allow for scripts to detect if they are being run within OliveTin.

  3. The environment variables are passed into the execution context which uses a shell (/bin/sh on Linux), so it is also possible to use them with the $ notation in the shell line, like this; shell: echo $FILENAME for example.