Configuration for Lua script execution

You must configure the transfer server by using the aspera.conf file to run Lua scripts automatically.

First, you add a <transfer> element to aspera.conf. Then, within the <transfer> element, you add subelements to identify the transfer events and the scripts. The scripts can be identified by path name, or the base64 encoded version of the scripts (or path to the scripts) can be used directly.

Scripts can access transfer session data, which is stored in a Lua table (env_table[]). They can also use several functions that are provided to facilitate file system operations, logging, and aborting a session.

Note: The Lua built-in print() function, as well as any other functions that interact with SDTIN or STDOUT, must not be used because they might interfere with session data and cause transfers to fail.

Event types

Scripts can be automatically run at each of these events:
  • Session start.
  • Session stop.
  • Session progress.
  • File start.
  • File stop.
Note: Session progress reporting is initiated when a file transmission starts. Transfer status is then updated every second during transmission.

Event type and script specification

Within the <transfer> element, you use subelements that identify the type of event and the script that runs at that event. You can identify the script by its path name, or you can use the base64 encoding of the script itself. A script can be used for more than one event, whether referenced by its file path or included base64 encoded format.

To simplify developing your script, you might find it useful to temporarily specify the script by path name and by using base64 encoding of the script for a given execution event (in separate specification lines).

If both file path and base64 specifications are used, the path name-based specification overrides a base64 specification.

Session Start
<lua_session_start_script_base64></lua_session_start_script_base64>
<lua_session_start_script_path></lua_session_start_script_path>
Session Stop
<lua_session_stop_script_base64></lua_session_stop_script_base64>
<lua_session_stop_script_path></lua_session_stop_script_path>
Session Progress
<lua_session_progress_script_base64></lua_session_progress_script_base64>
<lua_session_progress_script_path></lua_session_progress_script_path>
File Start
<lua_file_start_script_base64></lua_file_start_script_base64>
<lua_file_start_script_path></lua_file_start_script_path>
File Stop
<lua_file_stop_script_base64></lua_file_stop_script_base64>
<lua_file_stop_script_path></lua_file_stop_script_path>

Configuration Examples

Consider, for example, a file that is called luascript, which contains this code:

lua_log("Hello from lua-land")
If luascript is in /home/xeno, the following configuration causes the script to be run when a file transfer starts:
<transfer>
<lua_file_start_script_path>/home/xeno/luascript</lua_file_start_script_path>
</transfer>
If you wanted to use the base64-encoded version of the script itself, or the encrypted path name for the script, then the configuration would look something like this:
<transfer>
<lua_session_start_script_base64>bHVhX2xvZygiSGVsbG8gZnJvbSBsdWEtbGFuZCIp</lua_session_start_script_base64>
</transfer>