Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Info
titleUNIX

This sample is a Bourne shell script that uses a combination of environment variables set by the UEM Server, the script's process ID, and the current system date/time in order to construct a unique file name used to store the output of the ls -al command.


Expandpanel
#!/bin/sh

rc=0

## Set a date string in the format yyyy.mm.dd.
dt=`date +%Y.%m.%d`

## Set a time string in the format hh.mm.ss
tm=`date +%H.%M.%S`

## Save the process ID
pid=$$

## Remove the extension from the file tracked by UEM.
uemFName=`basename "$UEMORIGFILE" | sed 's/(^.*).(.*)/1/'`

## Construct a filename using the name of the file tracked by UEM, the
## current date, the current time, and the process ID.
fname=$uemFName.$dt.$tm.$pid.txt

## Execute the command. Redirect the output to the file name 
## constructed above.
ls -al >$fname

## Set the return code and exit the script
rc=$?
exit $rc

...