UNIX - Integrating UDM with FTP Using a Shell Script

UNIX - Integrating UDM with FTP Using a Shell Script

Remote process may require coordination with UDM. The exec command provides a method for this coordination.

In this example, a file is transferred into a secure area behind a firewall and then is forwarded to a second system using FTP. In actual practice, the same file could be forwarded to multiple systems using FTP, and then the exec command used to send notices to those same systems.

For simplicity, the file is "pulled" to the local system using UDM and then "pushed" to the remote system inside of the firewall using FTP. UDM's three-party transfer capability allows transferring a file from one remote system to another and initiating processes on either of those remote systems, the local system, or any other system running a UCMD Server.

The example was tested using a Windows system as the remote system from which the file is initially pulled. The example would work without change if the remote system were a UNIX system. The local test system on which the UDM Manager runs is Linux and the test system to which the file is sent using FTP is also Linux.


1. set echo=yes
2. open rmt=192.168.20.47 user=joe pwd=abcdefg port=7887
3. mode type=text
4. attrib local createop=replace
5. cd rmt=C:\tmp\tmp
6. cd local=/home/joe/wrk/xmp/dmzFtp
7. copy rmt=file.txt.org local=file.txt
8. exec local cmd="sh /home/joe/wrk/xmp/dmzFtp/ftp.sh" user=joe pwd=abcdefg port=7887
9. exec dev-linux24 cmd="ls /home/joe/tmp" user=joe pwd=abcdefg port=7887
10. quit 

UDM Script Explanation

  1. Turns echo on to put the commands into the transaction log.
  2. Open a connection to the remote UDM server using remote port 7887. The open command assigns the logical name 'rmt' to the remote system at IP address 192.168.20.47 and assigns the logical name local to the system on which the UDM Manager is running. Setting up local is done automatically by UDM for two-party transfers when a second system is not specified.
  3. Change the transfer mode from binary to text.
  4. Change the Creation Option attribute for the local server from new to replace. Without this change, existing files cannot be replaced with new copies.
  5. Change the current directory on the remote Windows system to C:\tmp\tmp. This is the directory from which the file is pulled.
  6. Change the current directory on the local UNIX system to /home/joe/wrk/xmp/dmzFtp. This is the directory into which the file is pulled.
  7. Use the UDM copy command to transfer the file from the remote Windows system to the local UNIX system.
  8. Execute the shell script on the local system to FTP the file to the 2nd system inside the firewall. In this example, the exec command uses the UCMD server running on the local system to execute the shell script just as if it resided on a remote system. The port must be specified on the command if it is set to a value other than the default value.
  9. Execute the ls command on the remote system to show that the file was copied. In a production environment, a process could be started to do something productive with the transferred file.
  10. Quit command stops UDM script execution and the UDM script completes.


The shell script sets up and executes FTP commands.

ftp -ipnv houston <

UDM exec Command Parameters

The exec command parameters used in this example are:

Parameter

Description

cmd

Command to execute on the remote system using command type cmd (command).

user

Remote user ID with which to authenticate and execute the command on the remote system.

pwd

Password with which to authenticate the user ID on the remote system.

port

Port that the Universal Broker is listening on for the remote machine. The port is inherited from the UDM Manager's configuration file unless explicitly overridden in the call to the exec command.

Components

Universal Data Mover Manager for UNIX

Universal Command Server for UNIX