Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Redirection in .btm and from .btm

Aug
2,294
111
I have a .btm, which outputs to tmp9:
Code:
@setlocal
@echo off
echo %_isodate > tmp9:
endlocal

Works as designed.

If I run the following;
Code:
R:\>test.btm > tmp8:
TCC: (Sys) R:\test.btm [3]  The process cannot access the file because it is being used by another process.
 "r:\temp\COUT5368.JPS"

Should this work, or is this not possible using just redirection?

Joe
 
I don't quite understand the error message, but redirection affects the standard handles. If, inside the BTM, stdout is redirected to tmp9:, I figure the BTM isn't producing any stdout (to redirect to tmp8:).
 
This says something about the error message but I don't know what.

Code:
v:\> thread `delay 100 > tmp1:`

v:\> echo foo > tmp2:TCC: (Sys) The process cannot access the file because it is being used by another process.
 "C:\Users\vefatica\AppData\Local\Temp\COUT9ec.JPS"
 
Why is _stdout equal to 1 in both runs,
but errors in test.btm > tmp8:?

Code:
@setlocal
@echo off
echo _stdout: %_stdout
iff %_stdout eq 1 then
  echo Output is already redirected
else
  echo %_isodate > tmp9:
  type tmp9:
endif
endlocal

Code:
R:\>test.btm
_stdout: 1
Output is already redirected

R:\>test.btm > tmp8:
TCC: (Sys) R:\test.btm [7]  The process cannot access the file because it is being used by another process.
 "r:\temp\COUT47f0.JPS"

Joe
 
Doesn't _STDOUT == 1 mean it's not redirected?

It should be "endiff".
 
This looks right ... no?

Code:
v:\> type joe.btm
echo _stdout: %_stdout
iff %_stdout ne 1 then
  echo Output is already redirected
else
  echo %_isodate > tmp9:
  type tmp9:
endiff

v:\> joe.btm
_stdout: 1
2025-02-09

v:\> joe.btm > stdout.txt

v:\> type stdout.txt
_stdout: 0
Output is already redirected
 
Thanks Vince.

It was an endiff in my .btm, not sure what happened in the post.

Yep,
Code:
_STDOUT returns 1 if STDOUT points to the console, or 0 if it has been redirected.

Working now.

Code:
R:\>tmp 
TMP0:
TMP1:
TMP2:
TMP3:
TMP4:
TMP5:
TMP6:
TMP7:
TMP8: _stdout: 0
Output is already redirected

TMP9: 2025-02-09
 
You're trying to redirect STDOUT to two different places simultaneously; you cannot do that with redirection. (You can do it with pipes & PEE.)

The error message is because TMPn: is a TCC pseudo-device (not supported in Windows) so TCC has to create a temporary file in order to do the redirection.
 
Back
Top