We help IT Professionals succeed at work.

Nestif IF Exists

elwayisgod
elwayisgod asked
on
Medium Priority
91 Views
Last Modified: 2020-01-29
I have to add additinal logic to ensure the process is not running:

Current Code that works.  But need to add logic where file ' %TRIGGER_DIR%\%RUNNING%.trig' doesn't exist......

if exist %TRIGGER_DIR%\%JOB_NAME%.trig (
 call :RUNJOB
  ) else (
  call :QUIT
  )
:QUIT
exit 0

:RUNJOB

Open in new window

Comment
Watch Question

Bill PrewTest your restores, not your backups...
CERTIFIED EXPERT
Expert of the Year 2019
Top Expert 2016

Commented:

The simple approach (I'm assuming the real script may be more complex, so not trying to re-engineer the rest)...


if exist "%TRIGGER_DIR%\%JOB_NAME%.trig" (
    if not exist "%TRIGGER_DIR%\%RUNNING%.trig" (
        call :RUNJOB
    ) else (
        call :QUIT
    )
) else (
    call :QUIT
)

:QUIT
exit 0

:RUNJOB
Test your restores, not your backups...
CERTIFIED EXPERT
Expert of the Year 2019
Top Expert 2016
Commented:

Naturally, based on what's there, you could just "fall through" to the quit after the IF's, like:


if exist "%TRIGGER_DIR%\%JOB_NAME%.trig" (
    if not exist "%TRIGGER_DIR%\%RUNNING%.trig" (
        call :RUNJOB
    )
)

:QUIT
exit 0

:RUNJOB

Author

Commented:
I'll try the 2nd one.  Stand by

Author

Commented:
Worked as desired as usual :)

Thank You.  I was looking for old code as I did this before, but couldn't find it.  Probably different client.
Bill PrewTest your restores, not your backups...
CERTIFIED EXPERT
Expert of the Year 2019
Top Expert 2016

Commented:

Great Sam, glad that worked out!


»bp