Knowledgebase

Search:     Advanced search

Post-Event Triggers That Run Batch Files Do Not Work

Article ID: 664  |  Last updated: 23 Dec, 2014

Problem

Post-event triggers which run batch files that redirect output from sscm commands to a log file do not work if multiple files cause the trigger to fire. The log file only includes output from the first sscm command.

Cause

Post-event triggers that run scripts start multiple processes that may attempt to write to the log file at the same time. Only the first process completes successfully because of log file access conflicts.

Solution

Send the sscm command output for each affected file to a temporary file, append each temporary file to the log file, and then delete the temporary file.

In the following batch file example, the sscm get command copies each file affected by the trigger to the C:\test directory. The get command output is redirected to the temporary file in the C:\test directory. The temporary file is appended to the C:\test\SCMLogfile.txt log file and then deleted.

set SCMLOGFILE="C:\test\SCMLogfile.txt"
set MYDEST="C:\test"
sscm get "%SSCM_FILE%" -b"%SSCM_BRANCH%" -p"%SSCM_REPOSITORY%" -d"%MYDEST%" -yadministrator -zlocalhost:4900 >> C:\test""%SSCM_FILE%".tmp
type C:\test""%SSCM_FILE%".tmp >> %SCMLOGFILE%
del C:\test""%SSCM_FILE%".tmp

Article ID: 664  |   Last updated: 23 Dec, 2014
Tags
triggers batches

Prev   Next
Surround SCM Client System Requirements     Mapping a Network Drive to a WebDAV Directory Using WebDrive