Skip to main content
Version: 3.3

Command Task Examples

This page provides examples of Command Tasks that can be used to automate file management, logging, and testing actions during transfer processing.

These examples use supported Replacement Variables, such as ${FILE_PATH}, and demonstrate typical commands for Linux and Windows environments.

Usage Notes​

When configuring a Command Task, keep the following in mind:

  • Ensure that the command is valid for the operating system where UDMG Server is running.
  • Verify that the user account running UDMG Server has the necessary permissions to execute the command and access the referenced paths.
  • When using Replacement Variables, ensure that values are quoted appropriately, especially when file paths may contain spaces.
warning

Replacement Variables are expanded by UDMG before the command is executed. They are not operating system environment variables. Use the placeholder syntax ${VARIABLE_NAME} on both Linux and Windows.

File Management Operations​

Rename the File​

Description: Renames the processed file by appending .processed to the filename.

Recommended Event Types:

  • On Sent
  • On Received
  • On Error

Command:

mv "${FILE_PATH}" "${FILE_PATH}.processed"

Delete the File​

Description: Deletes the file after processing.

Recommended Event Types:

  • On Sent
  • On Received
  • On Error

Command:

rm -f "${FILE_PATH}"

Compress the File​

Description: Compresses the file after transfer.

Recommended Event Types:

  • On Sent
  • On Received

Command:

gzip -f "${FILE_PATH}"

Move the File to Another Directory​

Description: Moves the file to a different directory on the host system.

Recommended Event Types:

  • On Sent
  • On Received

Command:

mv "${FILE_PATH}" "/tmp/processed/"

Create a Copy of the File​

Description: Creates a backup copy of the file without modifying the original.

Recommended Event Types:

  • On Sent
  • On Received

Command:

cp "${FILE_PATH}" "${FILE_PATH}.bak"

Logging​

Write Transfer Metadata to a Log File​

Description: Writes transfer-related metadata to a log file using replacement variables.

Recommended Event Types:

  • On Sent
  • On Received
  • On Error

Command:

sh -c 'echo "TransferID=${TRANSFER_ID}, User=${ACCOUNT_USERNAME}, Protocol=${PROTOCOL}, File=${FILE_PATH}" >> /tmp/transfer.log'

Testing​

Fail Intentionally​

Description: Executes a command that fails, which can be used to test error handling and Task execution behavior.

Recommended Event Type:

  • On Error

Command:

ls /nonexistent_directory