Topic
IC4NOTICE: developerWorks Community will be offline May 29-30, 2015 while we upgrade to the latest version of IBM Connections. For more information, read our upgrade FAQ.
2 replies Latest Post - ‏2013-07-15T20:25:44Z by rainer.oye@it-qbase.de
JHops
JHops
31 Posts
ACCEPTED ANSWER

Pinned topic Trouble logging ccm.exe output from Windows Batch Script

‏2013-06-12T20:17:28Z |

Hello,

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

  • JHops
    JHops
    31 Posts
    ACCEPTED ANSWER

    Re: Trouble logging ccm.exe output from Windows Batch Script

    ‏2013-06-19T18:35:09Z  in response to JHops

    Update: I have gotten a work around for this, but still not ideal.  What seems to work is to use a separate log file for each step of the script.  I'd still rather log to one file serially.

    • rainer.oye@it-qbase.de
      10 Posts
      ACCEPTED ANSWER

      Re: Trouble logging ccm.exe output from Windows Batch Script

      ‏2013-07-15T20:25:44Z  in response to JHops

       

      I don't know how your perl scripts work. but did you try the following things?

      - don't redirect output in your perl scripts. use redirection only in the batch.

      - try the "call" command to call your perls and check what happens then. (call perl ...)

      - and both combined.

      - remove the "REM funny syntax" comment, maybe Windows gets angry on you with this.  ;)

      Greets, Rainer