ie8 fix

Windows 2000/NT forum: Concuurency with my Windows Batch Script

by: vaman00 January 21, 2010 2:02 PM PST

Like this

0 people like this thread

Staff pick

Concuurency with my Windows Batch Script

by vaman00 - 1/21/10 2:02 PM

I am trying to run this script with the hope that it can be invoked by multiple jobs at the same time but i am getting the following error concurrency message. I have ensured the logs files are different to each job unless windows doesn't handle the random numbers properly. I can't fugre out what the problem is. Please help. My unix script for the same functionality works wonderfully

"The process cannot access the file because it is being used by another process."

Here is the script

:: ------------------------------------------------------------------
:: PROGRAM: esplmi.cmd
:: JOB : this script can be invoked by any script that would like
:: ESP event trigger condition to be created by passing the
:: ESP event trigger condition name
::
:: ------------------------------------------------------------------
:: The general logic of this script is as follows:
:: - Read ESP event trigger condition parameter
:: - Invoke ESPlmi with the read parameter
:: --------------------------------------------------------------:: ------------------------------------------------------------------
:: - Added logic after for ESPlmi failure condition, to sleep
:: and try again (5 times). After continued failures - ftp file to sliudv91
::
:: ------------------------------------------------------------------

:: ------------------------------------------------------------------
:: Set up variables
:: ------------------------------------------------------------------

@ECHO OFF

set CONDITION=%1

set t=%time:~0,8%
set t=%t::=-%

set UNIQUENO=%RANDOM%
set CURRENT_DIR=C:\esp\scripts
set ESP_LOG_DIR=%CURRENT_DIR%
set LOGFILE="%ESP_LOG_DIR%\esplmi_today_%UNIQUENO%.log"
set SLOGFILE="%ESP_LOG_DIR%\esplmi_success_%UNIQUENO%.log"
set ERRORFILE="%ESP_LOG_DIR%\ESP_TRIG_FAILED_%UNIQUENO%.txt"
set SERVER=%COMPUTERNAME%

set ESP_AGENT_ENV=%2
set PASS=1


:: -----------------------------------------------------------------------------
:: Execute the ESP Event triggering agent
:: -----------------------------------------------------------------------------
ECHO. > %LOGFILE%
ECHO "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" >> %LOGFILE%
ECHO "%Date% %TIME% Started: ESPlmi Event trigger script has started." >> %LOGFILE%
ECHO. >> %LOGFILE%
CD %CURRENT_DIR%

:ESPLMILOOP
C:\PROGRA~1\Cyberm~1\ESPSYS~1\esplmi -c"oper tr %ESP_AGENT_ENV%.conditon_1 user1(%CONDITION%)" >> %LOGFILE%
find "EVENT TRIGGERED" %LOGFILE% > %SLOGFILE%

IF ERRORLEVEL 1 GOTO ERROR
IF ERRORLEVEL 0 GOTO SUCCESS

:ERROR
ECHO. >> %LOGFILE%
ECHO "%Date% %TIME% Error: ESP trigger %CONDITION% failed in Pass %PASS%" >> %LOGFILE%
ECHO. >> %LOGFILE%


ECHO "485" > %ERRORFILE%
ECHO "%SERVER%" >> %ERRORFILE%
ECHO "%CONDITION%" >> %ERRORFILE%
ECHO "%PASS%" >> %ERRORFILE%


IF "%PASS%"=="1" GOTO FTP
IF "%PASS%"=="2" GOTO FTP
IF "%PASS%"=="3" GOTO FTP
IF "%PASS%"=="4" GOTO FTP
IF "%PASS%"=="5" GOTO FTPEND



:SUCCESS
ECHO. >> %LOGFILE%
ECHO "%Date% %TIME% SUCCESS: ESP trigger %CONDITION% created in Pass %PASS% " >> %LOGFILE%
ECHO. >> %LOGFILE%
ECHO "%Date% %TIME% Ended: ESPlmi Event trigger script has Ended." >> %LOGFILE%

TYPE %LOGFILE%
::ERASE %LOGFILE% > NUL
::ERASE %SLOGFILE% > NUL
GOTO END

:FTP
ECHO "No manual intervention is needed. Retrying it again" >> %ERRORFILE%
c:\windows\system32\ftp -v -s:%CURRENT_DIR%\sliudv91.txt sliudv91
TYPE %LOGFILE%
::ERASE %LOGFILE% > NUL
::ERASE %SLOGFILE% > NUL
::ERASE %ERRORFILE% > NUL
TIMEOUT 60
SET /A PASS=%PASS%+1
GOTO ESPLMILOOP

:FTPEND
ECHO "Manual intervention is needed." >> %ERRORFILE%
c:\windows\system32\ftp -v -s:%CURRENT_DIR%\sliudv91.txt sliudv91
TYPE %LOGFILE%
::ERASE %LOGFILE% > NUL
::ERASE %SLOGFILE% > NUL
::ERASE %ERRORFILE% > NUL
GOTO END

:END

Forum Icon Legend

  • UnreadUnread
  • ReadRead
  • Locked threadLocked thread
  •   
  •   
  •   
  •   
  •   
  •   
  •   
  • ModeratorModerator
  • CNET StaffCNET Staff
  • Samsung StaffSamsung Staff
  • Norton Authorized Support TeamNorton Authorized Support Team
  • AVG StaffAVG Staff
  • avast! Staffavast! Staff
  • Webroot Support TeamWebroot Support Team
  • Acer Customer Experience TeamAcer Customer Experience Team
  • Windows Outreach TeamWindows Outreach Team
  • DISH staffDISH staff
  • Dell StaffDell Staff
  • Intel StaffIntel Staff
  • QuestionQuestion
  • Resolved questionResolved question
  • General discussionGeneral discussion
  • TipTip
  • Alert or warningAlert or warning
  • PraisePraise
  • RantRant

You are e-mailing the following post: Post Subject

Your e-mail address is used only to let the recipient know who sent the e-mail and in case of transmission error. Neither your address nor the recipient's address will be used for any other purpose.

Sorry, there was a problem emailing this post. Please try again.

Submit Email Cancel

Thank you. Sent email to

Close

Thank you. Sent email to

Close

You are reporting the following post: Post Subject

If you believe this post is offensive or violates the CNET Forums' Usage policies, you can report it below (this will not automatically remove the post). Once reported, our moderators will be notified and the post will be reviewed.

Offensive: Sexually explicit or offensive language

Spam: Advertisements or commercial links

Disruptive posting: Flaming or offending other users

Illegal activities: Promote cracked software, or other illegal content

Sorry, there was a problem submitting your post. Please try again.

Submit Report Cancel

Your message has been submitted and will be reviewed by our staff. Thank you for helping us maintain CNET's great community.

Close

Your message has been submitted and will be reviewed by our staff. Thank you for helping us maintain CNET's great community.

Close

You are posting a reply to: Post Subject

The posting of advertisements, profanity, or personal attacks is prohibited. Please refer to the CNET Forums policies for details. All submitted content is subject to CBS Interactive Site Terms of Use.

You are currently tracking this discussion. Click here to manage your tracked discussions.

If you're asking for technical help, please be sure to include all your system info, including operating system, model number, and any other specifics related to the problem. Also please exercise your best judgment when posting in the forums--revealing personal information such as your e-mail address, telephone number, and address is not recommended.

Sorry, there was a problem submitting your post. Please try again.

Sorry, there was a problem generating the preview. Please try again.

Duplicate posts are not allowed in the forums. Please edit your post and submit again.

Submit Reply Preview Cancel

Thank you, , your post has been submitted and will appear on our site shortly.

Close