Pre-send Jobs, Post-send Jobs, and Post-receive Jobs
You can register jobs that are executed before and after Agent transfers files in the transfer settings.
(1) Pre-send Jobs
Jobs that are executed on the Agent environment just before transferring files are called "Pre-send Jobs".

Figure 2.3 Execution of Pre-send Jobs
1. A job is executed on the Agent environment before transferring files.
2. Agent transfers the files.
(2) Post-send Jobs
Jobs that are executed on the Agent environment after transferring files are called "Post-send Jobs". Post-send Jobs are divided into the following two types:
- Successful Jobs
-
These jobs are executed when files have been sent successfully.
- Unsuccessful Jobs
-
These jobs are executed when the attempts to send files fail.
Figure 2.4 Execution of Post-send Jobs
1. Agent receives an end code of the file transfer.
2. If the end code of the file transfer is 0, a Successful Job is executed. If the end code is not 0, an Unsuccessful Job is executed.
Jobs that are executed on the Manager environment after transferring files are called "Post-receive Jobs". Post-receive Jobs are divided into the following two types:
- Successful Jobs
-
These jobs are executed when files have been sent successfully.
- Unsuccessful Jobs
-
These jobs are executed when the attempts to send files fail.
Figure 2.5 Execution of Post-receive Jobs
1. HULFT receives files from Agent.
2. If an end code of the file transfer is 0, a Successful Job is executed. If the end code is not 0, an Unsuccessful Job is executed.
(4) Usage of environment variables
You can use the different environment variables according to the jobs.
- Available environment variables
-
The following table shows the environment variables which can be used in pre-send jobs and post-send jobs:
Table 2.2 Available environment variables in pre-send jobs and post-send jobs
Variable Name Conversion Rule FILEID Converts to the file ID of the transfer file.
FILENM Converts to the file name of the transfer file.
-
The following table shows the environment variables which can be used in post-receive jobs:
Table 2.3 Available environment variables in post-receive jobs
Variable Name Conversion Rule HOST Converts to the receiving host name. FILEID Converts to the file ID of the transfer file. COUNT Converts to the number of the received records. FILENM Converts to the reception file name. STATUS Converts to the reception status code. †
DETAIL Converts to the reception detail code. †
SDATE Converts to the reception start date in YYMMDD format. EDATE Converts to the reception end date in YYMMDD format. STIME Converts to the reception start time in HHMMSS format. ETIME Converts to the reception end time in HHMMSS format. SDATE2 Converts to the reception start date in YYYYMMDD format. EDATE2 Converts to the reception end date in YYYYMMDD format. †
:
For details about codes, see the HULFT manual Error Codes and Messages.
(5) Example job
You can find an example of the post-send job and the post-receive job.
- Example of the Post-send job (in Windows)
-
This is an example of the usage of environment variables in a post-send job:
Table 2.4 Conversion example of environment variables (Post-send job)
Environment variable Description Conversion value %FILENM% The name of the file that was transferred to HULFT C:\temp\monitored\test.txt
-
This is an example of the description of environment variables in a post-send job to delete transferred file:
@echo off echo The following file was transferred to HULFT and it is deleted by Agent: %FILENM% >> "C:\HULFT Family\hulftiot\user.log" del %FILENM% :end
If you execute the example above with applying the conversion example indicated in the table, the transferred file will be deleted with the indication as follows:
The following file was transferred to HULFT and it is deleted by Agent: C:\temp\monitored\test.txt
- Example of the Post-send job (in Linux)
-
This is an example of the usage of environment variables in a post-send job:
Table 2.5 Conversion example of environment variables (Post-send job)
Environment variable Description Conversion value $FILENM The name of the file that was transferred to HULFT /tmp/monitored/test.txt
-
This is an example of the description of environment variables in a post-send job to delete transferred file:
#! /bin/sh echo The following file was transferred to HULFT and it is deleted by Agent: $FILENM >> user.log rm $FILENM
If you execute the example above with applying the conversion example indicated in the table, the transferred file will be deleted with the indication as follows:
The following file was transferred to HULFT and it is deleted by Agent: /tmp/monitored/test.txt
- Example of the Post-receive job (in Windows)
-
This is an example of the usage of environment variables in a post-receive job:
Table 2.6 Conversion example of environment variables (Post-receive job)
Environment variable Description Conversion value %$HOST% Reception host name HOST0001 %$FILEID% File ID of the transferred file
FILEID01 %$SDATE2% Start date of the reception 20180815 %$STIME% Start time of the reception 155400 %$EDATE2% End date of the reception 20180815 %$ETIME% End time of the reception 160232 %$COUNT% The number of the received records 12000 %$STATUS% Reception status code 0 %$FILENM% The received file name C:\temp\received\result.txt
-
This is an example of the description of environment variables in a post-receive job to output the received file information to the standard output:
@echo off echo %$HOST% %$FILEID% %$SDATE2% %$STIME% %$EDATE2% %$ETIME% echo count=%$COUNT% status=%$STATUS% if not %$STATUS% == 0 goto end echo %$FILENM% :end
If you execute the example above with applying the conversion example indicated in the table, the received result information will be output as follows:
HOST0001 FILEID01 20180815 155400 20180815 160232 count=12000 status=0 C:\temp\received\result.txt
- Example of the Post-receive job (in Linux)
-
This is an example of the usage of environment variables in a post-receive job:
Table 2.7 Conversion example of environment variables (Post-receive job)
Environment variable Description Conversion value $HOST Reception host name HOST0001 $FILEID File ID of the transferred file FILEID01 $SDATE2 Start date of the reception 20180815 $STIME Start time of the reception 155400 $EDATE2 End date of the reception 20180815 $ETIME End time of the reception 160232 $COUNT The number of received records 12000 $STATUS Reception status code 0 $DETAIL Reception detail code 0 $FILENM The received file name /tmp/received/result.txt
-
This is an example of the description of environment variables in a post-receive job to output the received file information to the file:
#! /bin/sh echo $HOST $FILEID $SDATE2 $SITME $EDATE2 $ETIME > user.log echo count=$COUNT status=$STATUS detail=$DETAIL >> user.log if [ $STATUS -eq 0 ] then echo $FILENM >> user.log cp $FILENM $FILENM.bakfi
If you execute the example above with applying the conversion example indicated in the table, the received result information will be output as follows:
HOST0001 FILEID01 2018015 1555400 20180815 160232 count=12000 status=0 detail=0 /tmp/received/result.txt
(6) Specifying the job execution mode
On the [Job] tab of the transfer settings screen, specify the job execution mode of pre-send jobs and post-send jobs (both Successful Jobs and Unsuccessful Jobs).
Job conditions | Job execution mode | ||
---|---|---|---|
Step Execution | Script Execution | ||
Job to be executed |
- Indicate the commands that you want to execute. - Multiple commands can be used. |
- Indicate the script file that you want to execute. - The supported script formats depend on the OS and the environment. |
|
In Windows | Commands that can be executed from a command prompt | Batch files that can be executed from a command prompt | |
In Linux | Commands that can be executed from the login shell that is allocated to the executor of Agent | Shell script files composed of commands that can be interpreted by the Bourne shell |
|
Judgment |
- When the return value of the command is 0: Manager judges that the command ends normally. - When the return value of the command is other than 0: Manager judges that the command ends abnormally. Manager suspends an execution of the command and the subsequent commands are not executed. |
- If the status code of the script file is 0: Manager judges that the script file ended normally. - If the status code of the script file is not 0: Manager judges that the script file ended abnormally. |
|
: |
For details about the commands that can be executed via shell scripts, check the specifications of /bin/sh for the installation destination OS. |