Windows Directory Listing Using a Batch File - Returned File

Windows Directory Listing Using a Batch File - Returned File

This example builds on the example illustrated in Windows Directory Listing Using a Batch File - Default Directory.

Keep in mind that both the batch file and the file created by the redirected output reside on the remote system.

1 set echo=no
2 set outdir=C:\tmp\joe
3 open r=dallas user=joe pwd=abcdefg
4 exec r cmd="C:\wrk\xmp\win\winxmp.bat $(outdir)\stdout.txt" user=joe pwd=abcdefg
5 cd r=$(outdir)
6 cd local=C:\tmp\tmp
7 attrib local createop=replace
8 copy r=stdout.txt
9 exec local cmd="type C:\tmp\tmp\stdout.txt" user=joe pwd=abcdefg
10 quit

Due to the complexity of this example, each line (numbered for your convenience) is explained, below.

  1. Echo is turned off to minimize the amount of information in the transaction log due to its size. You are encouraged to set up the example and work through the transaction log.
  2. Set a variable, outdir, for later use. Instead of setting the variable inside of the UDM script, the variable and its associated value could have been provided externally via a script option.
  3. Open the UDM connection for a two-party transfer. The manager will act as the primary server and is known as local.
  4. Execute the remote command passing the full path to the file for the redirected output. Note the use of the variable inside of the double quotations; this is a UDM feature.
  5. Change the directory for the remote system to the directory in which stdout.txt resides.
  6. Change the directory for the local system to the location in which you want stdout.txt to reside.
  7. Set the attribute for the local system to allow replacement of the incoming file.
  8. Perform the file copy.
  9. Execute a command on the local system to display the contents of the received file. UCMD server runs on the local system just as it would on the remote system to execute the command.
  10. Quit and exit the UCMD Manager.


The winxmp.bat batch file now echoes the received parameter. This puts output into the transaction log so that you can see what was passed to the remote system. The second line performs the dir command and redirects output to stdout.txt.

echo %1
dir "C:\wrk\xmp\win" > %1


Output sent to stdout.txt.

C:\Program Files\Universal\UCmdHome\joe>dir "C:\wrk\xmp\win"
 Volume in drive C has no label.
 Volume Serial Number is 3030-176B

 Directory of C:\wrk\xmp\win

07/27/2011  03:27 PM    <DIR>          .
07/27/2011  03:27 PM    <DIR>          ..
07/27/2011  10:08 AM                20 winxmp.bat
07/27/2011  03:46 PM               106 winxmpbat.udm
               2 File(s)            126 bytes
               2 Dir(s)  13,453,979,648 bytes free

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.

Components

Universal Data Mover Manager for Windows

Universal Command Server for Windows