Automating & Scripting ZendTo

There are scripts provided in /opt/zendto/bin which allow you to use a command-line to:

autodropoff
Create a new drop-off
autolist
List everything stored about all drop-offs
autopickup
Download files from a drop-off, or list the files in a drop-off
autorequest
Send a request for a drop-off
Note: Please read the rest of this page before diving into each script.

The scripts are written in bash, and can be used as a reference implementation so that you can re-implement them in whatever system you need to, such as .Net on Windows. The scripts are all standalone, they can be run on a totally different server from your ZendTo server, their only dependency is the tiny "jq" package which manipulates JSON structures, and is widely available on all Linux/BSD distributions.

All the scripts actually do is take all your command-line options and use them to build a long curl command which does an HTTP POST request to your ZendTo server. The "--debug" option for all the scripts makes them print out the curl command rather than execute it.

Before you start

Before using any of the scripts, you need to create a user that will be only used for driving the automation scripts of ZendTo. Don't use a real user's account, create one just for the purpose.

Put that username in the 'automationUsers' setting in preferences.php.

This username will no longer work with the web interface, and other usernames will not work with the automation scripts. This is why you need to create a user specifically for this purpose.

Troubleshooting options

If you are using a locally-signed SSL certificate on your ZendTo server, you may need to add the option
    --insecure
to all of the example commands.

To see the curl command it creates, which is what does all the work, but not actually run anything, add the option
    --debug
to any of the example commands.

Re-implementing on another system

The reason curl was used is that all the script really does is create all the parameters for an HTTP POST request to your ZendTo server, and then pull out the JSON results from the right header in the returned data. The --debug option will help you understand what it's doing.

Once you have played with it a bit, take a look how the script works (90% is just parsing the command-line!) and you will see how you could use a .Net http request to achieve the same result with your own code running on a Windows server.