I cannot reproduce your results - when I run your code, everything seems to execute properly.
But I get similar illogical results as yours if I restructure the code and attempt to TYPE the job.bat instead of CALL it.
master.batCode: Select all
@echo off
setlocal EnableDelayedExpansion
title Master
start "Slave" "%comspec%" /c "slave.bat"
>nul ping -n 2 127.0.0.1
set count=0
for /l %%. in (1,1,10000) do (
if !count! lss 30 if not exist job.bat (
set /a count+=1
>job.bat.tmp echo !count!
ren job.bat.tmp job.bat
set count
)
)
slave.batCode: Select all
@echo off
for /l %%. in () do if exist "job.bat" (
type "job.bat"
del job.bat
)
--Master output--
Code: Select all
C:\test\>master
count=1
count=2
count=3
count=4
count=5
count=6
count=7
count=8
count=9
count=10
count=11
count=12
count=13
count=14
count=15
count=16
count=17
count=18
count=19
count=20
count=21
count=22
count=23
count=24
count=25
count=26
count=27
count=28
count=29
count=30
--Slave output--
Code: Select all
1
2
The process cannot access the file because it is being used by another process.
The process cannot access the file because it is being used by another process.
The process cannot access the file because it is being used by another process.
6
The process cannot access the file because it is being used by another process.
8
9
10
11
The process cannot access the file because it is being used by another process.
The process cannot access the file because it is being used by another process.
The process cannot access the file because it is being used by another process.
The process cannot access the file because it is being used by another process.
16
The process cannot access the file because it is being used by another process.
18
The process cannot access the file because it is being used by another process.
The process cannot access the file because it is being used by another process.
The process cannot access the file because it is being used by another process.
The process cannot access the file because it is being used by another process.
The process cannot access the file because it is being used by another process.
24
The process cannot access the file because it is being used by another process.
The process cannot access the file because it is being used by another process.
27
The process cannot access the file because it is being used by another process.
29
30
Just as in your more recent code, I must manually close the Slave window.
I don't understand why I get that particular error message - I cannot think of a logical reason for the job.bat file to be inaccessible to TYPE.
Here is another weird thing - if I change the temp file name from "job.bat" to "job.txt", then the failure rate is drastically reduced (not shown), but it still does fail a few times.
But anyway, after restoring the temp file name to job.bat, I then modify slave.bat to try again if the first TYPE fails. I also hide any error message from the first attempt:
slave.batCode: Select all
@echo off
for /l %%. in () do if exist "job.bat" (
2>nul type "job.bat"||type "job.bat"
del job.bat
)
-- Slave Output --
Code: Select all
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
Everything works now as expected
Okay... I can't explain why, but there seems to be some weird timing issue that makes the file unavailable for a time. So I thought we just need an appropriate delay...
But at
viewtopic.php?f=3&t=5824&p=46046#p46046 I tried incorporating a delay in the raycast demo before each compute engine attempts to execute the temporary job script, and it didn't solve the issue.
Dave Benham