Setting up and using pre-post processing

Introduction

Aspera transfer servers (Enterprise Server, Connect Server, Point to Point) allow custom actions to be executed before and after transfer sessions. The triggered actions can be executed before (pre-) and after (post-) each file transfer or session.

A batch script carries out this automation by executing your custom Perl scripts, shell commands, native executables and Java programs during the course of a transfer. Both the batch script and your custom scripts can make use of environment variables set by Aspera that provide transfer information, such as file size or the peer IP address.

The batch script is executed multiple times during a transfer session, as a result of the following four transfer events:

  • session start
  • session end
  • start of each individual file transfer in a session
  • end of each individual file transfer in a session


Additionally, there is a built-in pre-post application called Email Notification that generates custom emails based on transfer events. For more information on Email Notification, see the product documentation.

Setting Up

To set up the Pre- and Post- processing feature, follow the instructions below for your operating system.

Windows

1. If you would like to execute Perl scripts with pre-post processing, make sure you have it installed on your system. You can verify if you have Perl by running the following in a Command Prompt window:

perl -v

If Perl is supported on your system you will see a confirmation message showing the Perl version. If you do not see this you will need to download and install Active Perl from http://www.activestate.com/store/activeperl/download/

2. Locate the file aspera-prepost-email.bat in the following directory:

  • C:\Program Files (x86)\Aspera\[your product]\var

Make a copy of the aspera-prepost-email.bat file and rename it aspera-prepost.bat. You can accomplish this with the following command:

copy C:\Program Files (x86)\Aspera\[your product]\var\aspera-prepost-email.bat ^
C:\Program Files (x86)\Aspera\[your product]\var\aspera-prepost.bat

 

Linux, Solaris, FreeBSD

Locate the file aspera-prepost.disable in the following directory:

  • /opt/aspera/var

Make a copy of the aspera-prepost.disable file and rename it aspera-prepost. You can accomplish this with the following command:

cp /opt/aspera/var/aspera-prepost.disable /opt/aspera/var/aspera-prepost

 

Mac OS X

Locate the file aspera-prepost.disable in the following directory:

  • /Library/Aspera/var

Make a copy of the aspera-prepost.disable file and rename it aspera-prepost. You can accomplish this with the following command:

cp /Library/Aspera/var/aspera-prepost.disable /Library/Aspera/var/aspera-prepost

 

Isilon

Locate the file aspera-prepost.disable in the following directory:

  • /usr/local/aspera/var/

Make a copy of the aspera-prepost.disable file and rename it aspera-prepost. You can accomplish this with the following command:

cp /usr/local/aspera/var/aspera-prepost.disable /usr/local/aspera/var/aspera-prepost

 

Usage

When you have set up the pre-post processing feature, you can create your own custom scripts and include them in the batch file aspera-prepost (.bat) to be executed. For example, if you have the script my_custom_script.pl, you would add the following command in the batch file:

perl my_custom_script.pl

Within your scripts you will likely require information about the transfer sessions, such as if you only want to execute certain actions at the end of a transfer. The following are environment variables you can use to access certain specifications about the transfers. All variables can also be used in Email Notification.

Type Variable Value(s) Description

Session and File

COOKIE (string) The user-defined cookie string.
  DIRECTION send | recv The transfer direction.

 

ERRCODE (string) The error code.
  ERRSTR (string) The error string.
  MANIFESTFILE (string) The full path to the manifest file.
  PEER (string or valid IPv4 address) The peer name or IP address.
  SECURE yes | no Transfer encryption.
  SESSIONID (string) The session ID.
  STARTSTOP Start | Stop

The status of the transfer, whether it's at the beginning

(start) or at the end (stop).
  STATE started | success | failed The transfer state.
  TOKEN (string) The user-defined security token.
  TYPE Session | File The event type.
  USER (string) The user name.
  USERID (string) The user ID.
  USERSTR (string) The user string, such as additional variables.
Session FILE_CSUM (string)

Destination checksum of the most recently transferred

file.

  FILE1 (string) The first file.
  FILE2 (string) The second file.
  FILECOUNT (positive integer) The number of files.
  FILELAST (string) The last file.
  LICENSE (string) The license account and serial number.
  MINRATE (positive integer) The initial minimum rate, in Kbps.
  PEERLICENSE (string) The peer's license account and serial number.
  RATEMODE adapt | fixed The transfer policy.
  SOURCE (string) The full path of the source directory.
  TARGET (string) The full path of the target directory.
  TARGETRATE (positive integer) The initial target rate, in Kbps.
  TOTALBYTES (positive integer) The total bytes transferred.
  TOTALSIZE (positive integer) The total size of files being transferred in bytes.
File DELAY (positive integer) The measured network delay, in ms.
  FILE (string) The file name.
  LOSS (double-digit fixed point value) The network loss in percentage.
  OVERHEAD (positive integer) The total number of duplicate packets.
  RATE (double-digit fixed point value) The transfer rate in Kbps.
  REXREQS (positive integer) The total number of retransmission requests.
  SIZE (positive integer) The file size in bytes.
  STARTBYTE (positive integer) The start byte if resumed.

 

Example

On Linux and Unix based systems, the following custom script changes file permissions after a file transfer has ended, and logs the file name:

if [ $TYPE == File ]; then
  if [ $STARTSTOP == Stop ]; then
    echo "The file is: $FILE" >> /tmp/p.log
    chmod 777 $FILE
  fi
fi

 The following changes file permissions and logs the file name after a file transfer has ended on Windows:

if "%TYPE%" == "File" (
  if "%STARTSTOP%"=="Stop" (
    Echo The file is: %FILE% >> C:\temp\p.log
    cacls %FILE% /g everyone:f
  )
)

 

Have more questions? Submit a request

0 Comments

Article is closed for comments.
Powered by Zendesk