Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Attempts to write to the same log file within one batch script results in: The process cannot access the file because it is being used by another process.

$
0
0

All -

I've been trying to setup an automated process on our Windows 2003 server.  I'm running this batch scripts:

@echo off set CCM_HOME=c:\progra~1\ibm\rational\synergy\7.2 set PATH=%path%;c:\progra~1\ibm\rational\synergy\7.2\bin 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 thre current date/time in the log file echo . >> D:\TCP_WORK_AREA\update_log4.txt echo . >> D:\TCP_WORK_AREA\update_log4.txt echo %DATE% %TIME% >> D:\TCP_WORK_AREA\update_log4.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_log4.txt perl D:\TCP_WORK_AREA\CSI_EXTERNAL_UTILS\0.0\CsiSynergyUtils\renameDirsForSynergy.pl D:\TCP_WORK_AREA\CSI_CORE >> D:\TCP_WORK_AREA\update_log4.txt 2>&1 perl UPDATE_TCP_WA.pl >> D:\TCP_WORK_AREA\update_log4.txt 2>&1 echo "Running Setup Subprojects!" >> D:\TCP_WORK_AREA\update_log4.txt cd D:\TCP_WORK_AREA\CSI_EXTERNAL_UTILS\0.0\CsiSynergyUtils perl -I "D:\TCP_WORK_AREA\CSI_EXTERNAL_UTILS\0.0\CsiSynergyUtils" subProjectSetup.pl \\astvden-amslab\TCP_WORK_AREA >> D:\TCP_WORK_AREA\update_log4.txt 2>&1 echo "Renaming CSI_CORE Dirs For MATLAB" >> D:\TCP_WORK_AREA\update_log4.txt perl D:\TCP_WORK_AREA\CSI_EXTERNAL_UTILS\0.0\CsiSynergyUtils\renameDirsForMatlab.pl D:\TCP_WORK_AREA\CSI_CORE >> D:\TCP_WORK_AREA\update_log4.txt 2>&1 echo "Stopping Synergy Session" >> D:\TCP_WORK_AREA\update_log4.txt ccm stop >> D:\TCP_WORK_AREA\update_log4.txt 2>&1 REM All done so remove the UPDATE_IN_PROGRESS file del D:\TCP_WORK_AREA\UPDATE_IN_PROGRESS.txt

Everything runs fine up to 17, when the script dies with the message: "The process cannot access the file because it is being used by another process".  Afterwards, subsequent calls to this script will die immediately with the same message until I change the log file name.  I've been stumped by this one, because there's no other scripts running and no other processes that should have update_log4.txt open.  Although now that I'm writing this up , I noticed that I do CD to another directory just before line 17.  Would that cause problems like this?

Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>