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.
Output sent to stdout.txt.
Output sent to the UDM transaction log via stdout from the UDM Manager.
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. |