UNIX - Listing Using a Shell Script
UNIX Listing Using a Shell Script
In this example, the exec command runs on a UNIX system via UCMD Manager and executes the sh command to a remote UNIX system using UCMD Server. With a shell interpreter, such as Cygwin, installed under Windows, the same example would also apply to a Windows system. The example was tested using Linux as both the local and remote platforms.
Both the shell script and the file created by the shell script reside on the remote system. If you are walking through all the examples in order, notice that in this example the shell script redirects stdout to the stdout.txt file, whereas in the Windows example the command initiated by the remote UCMD server redirected stdout to the stdout.txt file.
Due to this difference, in this example stdout.txt is created in the current directory as set by the shell script and in the Windows example it is created in the UCMD server working directory.
UDM Script Explanation
- Turns echo on to put the commands into the transaction log.
- Open a connection to the remote UDM server using remote port 7887. This is the default port and can be changed by setting the port number in the Universal Broker configuration file on the remote system. When the port number is changed, Universal Broker on the remote system on which the configuration file change was made must be stopped and then started.
- Execute the shell script on the remote system. The port must be specified on the command if it is set to a value other than the default value.
- Quit command stops UDM script execution and the UDM script completes.
The shell script changes the current directory, generates the listing via the ls shell command, redirects the output of the ls command to the stdout.txt file and then uses the cat shell command to output the contents of stdout.txt to the stdout stream.
The stdout stream is returned by the UDM Server to the UDM Manager and is output to the transaction log.
cd /home/joe/wrk/xmp/ls ls > stdout.txt cat stdout.txt
Output sent to stdout.txt.
ls.sh stdout.txt
Output sent to the UDM transaction log via stdout from the UDM Manager.
2011.07.28 10.13.06.845 UNV2800I Universal Data Mover 6.3.0 Level 0 Release Build 104 started. 2011.07.28 10.13.06.845 Processing script: ls.udm 2011.07.28 10.13.06.847 open r=houston user=joe pwd=* port=7887 2011.07.28 10.13.07.114 Data session established using cipher: NULL-MD5 2011.07.28 10.13.07.159 Two party session established with r (component 1278600806) 2011.07.28 10.13.07.161 Transfer mode settings: 2011.07.28 10.13.07.198 type=binary 2011.07.28 10.13.07.198 trim=no 2011.07.28 10.13.07.198 Session options: 2011.07.28 10.13.07.198 Keep Alive Interval: 120 2011.07.28 10.13.07.198 Network Fault Tolerant: yes 2011.07.28 10.13.07.198 exec r cmd="sh /home/joe/wrk/xmp/ls/ls.sh" user=joe pwd=* port=7887 ls.sh stdout.txt 2011.07.28 10.13.08.072 quit 2011.07.28 10.13.08.074 Session closed 2011.07.28 10.13.08.074 Finished processing script: ls.udm 2011.07.28 10.13.10.074 UNV2801I Universal Data Mover 6.3.0 Level 0 Release Build 104 ended successfully.
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. |