Skip to content

Create a Job Action that Executes a Command

Create a Job Action that Executes a Command

For this demonstration we'll use a system command as a stand-in for the security software required by Don's company. The command will save the filename and time to a text file. If this succeeds, we'll consider the file "safe." In the real world, this command could be replaced by any security software your company needs to run.

Create a Job to screen outgoing reports

  1. Log into Gateway Administrator as Don using the password you specified when you created this account.

  2. Go to Jobs > New.

  3. For Name enter Reports.

  4. For State, leave Disabled selected for initial testing. You can use the Run Now feature to test disabled Jobs. After you are satisfied that the Job runs as expected, you can select Enabled to run the Job at the specified scan interval.

  5. Under Source Files, select the SFTP server on which you created the accessible c:\reports directory. Click Browse and select the reports directory. This sets up the directory to be scanned. Any new or updated files in this directory will trigger the Job actions you configure.

  6. For this test, we want to scan and move only PDF documents. To do this, next to Filters, click Change.... Select Named and enter .*\.pdf in the text box. This regular expression filters for all files with a pdf file extension. Check to be sure you've entered it correctly, including both periods.

    Click OK to return to the New Job page.

  7. Under Actions, from the Add action... drop-down list, select Execute command. In the Execute Command dialog box, for Server, select your Reports Server. For Command, enter the following:

    cmd /c echo $FILENAME$ $DATE$ $TIME$ >> c:\reports\safefiles.txt
    

    This command will be our stand-in for a security test. For the purposes of this demo, if files can be successfully written to safefiles.txt, the test passes.

    Note

    On Windows servers, you need to precede DOS commands with cmd /c. The /cswitch specifies that cmd should exit after the specified command is carried out.

    Click OK to return to the New Job page.

  8. Under Success, click Change to configure email notifications. In the Success Action dialog box, click Enabled and enter the email address you used for Don's account. Use the Tokens button to add the $JOB_NAME$ token. It will be replaced with the Job name in the email message:

    Click OK to return to the New Job page.

  9. Create a Failure Action in the same way.

  10. Click Save.

Test your Job

  1. On the Reports server, copy one or more *.pdf files to c:\reports.

  2. In Gateway Administrator, go to the Jobs page, select the Reports Job and click Edit.

  3. Click Run Now to test the action. You'll see a Running Job message. This tells you the Job has been initiated. You can close this message at any time; it has no effect on execution of Job actions.

If the Job works, you should see a new file called safefiles.txt in the reports folder on your Reports server and you should receive a success notification in the email you specified.

If your Job did not work as expected, review these instructions, or refer to the testing notes and troubleshooting help in the Administrator's Guide.

Note

If you make modifications to your Job, ensure that there are new or updated files in the scanned directory before each test.

Make a copy of the working Job

  • In Gateway Administrator, go to the Jobs page, select the Reports Job and click Copy.

  • Confirm that you want to make the copy. This creates a new Job called Reports_copy1.