I've been trying to setup some automated tasks on our Windows 2003 server. I've setup a batch script which runs calls a perl script, which runs some ccm commands. The batch script is intended to redirect output of both STDOUT and STDERR to a log file. However, after my first perl script returns after starting a Synergy command line session, subsequent commands that append to the log file die with the message "The process cannot access the file because it is being used by another process". I used Sysinternal's process explorer to find out what process had an open handle to the log file, and it turns out to be javaw.exe.
Are there some best practices out there for logging output from ccm.exe from batch scripts that I'm missing. The script is below. Note that the perl script "UPDATE_TCP_WA.pl" is where a ccm session is started (uses the /m option).
@echo off set CCM_HOME=C:\Program Files\IBM\Rational\Synergy\7.2 set PATH=C:\Program Files\IBM\Rational\Synergy\7.2\bin;%PATH% REM Put a file down so people know that update is in progress echo . >> D:\TCP_WORK_AREA\UPDATE_IN_PROGRESS.txt REM Put some newlines and the current date/time in the log file echo . >> D:\TCP_WORK_AREA\update_log8.txt echo . >> D:\TCP_WORK_AREA\update_log8.txt echo %DATE% %TIME% >> D:\TCP_WORK_AREA\update_log8.txt REM funny synax >> <FILENAME> 2>&1 redirects both STDOUT and STDERR to log file (use of double angle brackets appends rather than overwrites) REM Make sure the @ symbol directories are in place for Synergy echo "Renaming CSI_CORE Dirs For Synergy" >> D:\TCP_WORK_AREA\update_log8.txt perl D:\TCP_WORK_AREA\CSI_EXTERNAL_UTILS\0.0\CsiSynergyUtils\renameDirsForSynergy.pl D:\TCP_WORK_AREA\CSI_CORE 1>> D:\TCP_WORK_AREA\update_log8.txt 2>&1 perl UPDATE_TCP_WA.pl 1>> D:\TCP_WORK_AREA\update_log8.txt 2>&1 echo "Running Setup Subprojects!" >> D:\TCP_WORK_AREA\update_log8.txt perl -I "D:\TCP_WORK_AREA\CSI_EXTERNAL_UTILS\0.0\CsiSynergyUtils" subProjectSetup.pl \\astvden-amslab\TCP_WORK_AREA 1>> D:\TCP_WORK_AREA\update_log8.txt 2>&1 echo "Renaming CSI_CORE Dirs For MATLAB" >> D:\TCP_WORK_AREA\update_log8.txt perl D:\TCP_WORK_AREA\CSI_EXTERNAL_UTILS\0.0\CsiSynergyUtils\renameDirsForMatlab.pl D:\TCP_WORK_AREA\CSI_CORE 1>> D:\TCP_WORK_AREA\update_log8.txt 2>&1 echo "Stopping Synergy Session" >> D:\TCP_WORK_AREA\update_log8.txt ccm stop 1>> D:\TCP_WORK_AREA\update_log8.txt 2>&1 REM All done so remove the UPDATE_IN_PROGRESS file del D:\TCP_WORK_AREA\UPDATE_IN_PROGRESS.txt