Welcome!

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

SignUp Now!

TMP and re-direction

Aug
2,320
111
Using the command line;
Code:
R:\>(for %pid in ( %@pid[msedge.exe,+] ) do echo %pid) > r:\results.txt

...works as it should...
Code:
R:\>type r:\results.txt
14868
15096
15328
15336
14676
14432
14036
15536
15724
15780
22392
19352
7668
22068
6464
5884
3944
13780
772

I can re-direct the file contents to tmp9:
Code:
\R:\>type r:\results.txt > tmp9:

...and verify that tmp9: now contains the contents of r:\results.txt
Code:
R:\>type tmp9:
14868
15096
15328
15336
14676
14432
14036
15536
15724
15780
22392
19352
7668
22068
6464
5884
3944
13780
772

My end goal is to have the contents of the command line re-directed to tmp9:

So, I tried the following;
Code:
R:\>(for %pid in ( %@pid[msedge.exe,+] ) do echo %pid) > tmp9:

...but the redirection to tmp9: seems to be non-conformant...
Code:
R:\>type tmp9: 
1

R:\>tmp 
TMP0:
TMP1:
TMP2:
TMP3:
TMP4:
TMP5:
TMP6:
TMP7:
TMP8:
TMP9: 1

Would appreciate if others could duplicate this,
to ensure that I am not missing something.

Joe

Ref: @TMP not returning contents

Code:
     _x64: 1
   _admin: 1
_elevated: 1

TCC  32.10.21 x64   Windows 10 [Version 10.0.19045.4651]
 
I see a similar problem. Sending the output to the screen or redirecting to a file works; redirecting to tmp registers ends up storing garbage (my garbage is different from yours but still garbage).

-- Jay
 
The following command line will work:

Code:
tmp /c tmp9: & for %pid in (%@pid[msedge*,+]) echo %pid >> tmp9:

-- Jay
 
Thanks @Jay Sage

So, one must clear the pseudo character device before using it,
then output has to be appended,
instead of overwriting (makes sense).

Joe
 
It's not clear to me why one has to do that. As you noted, you can redirect the output to a file and then TYPE that file with redirection into a TMP: register. The following works fine:

Code:
(echo string1 & echo string2) > tmp9:

So I cannot understand why the output from the FOR command does not redirect the same way. I redirected the output to a file and looked for any strange character, but I did not see any. Each string ends with 0D 0A.
 
DO is no better.

Code:
v:\> (do x in /l string1 string2 (echo %x)) > out.txt

v:\> type out.txt
string1
string2

v:\> (do x in /l string1 string2 (echo %x)) > tmp9:

v:\> type tmp9:
ÿþs
 
Another example of non-conformant redirection to tmp9:

In this case, tmp9: remains empty.

This was my work around;
Code:
set theMonth=%@right[2,0%_month]
set theYear=%_year
tmp /c tmp9:
:: No results are sent to tmp9:
::dbf --filename r:\TRNSCTNS.DBF --csv |! ffields /C | ffind /vt"%theYear-%theMonth" > tmp9:
::
:: Workaround
dbf --filename r:\TRNSCTNS.DBF --csv |! ffields /C | ffind /vt"%theYear-%theMonth" > clip:
type clip: > tmp9:
type tmp9: | view
 
If I put the command that generates the output into a .btm;
Code:
for %pid in ( %@pid[msedge.exe,+] ) do echo %pid
...then call that .btm, re-directing output to tmp9:
Code:
test.btm > tmp9:
...it works as it should.

Ditto for;
Code:
dbf --filename r:\TRNSCTNS.DBF --csv |! ffields /C | ffind /vt"%theYear-%theMonth"

Thus, I cannot re-direct output from a command to tmp9:,
but if that command is in a .btm,
I can re-direct output to tmp9: via the .btm

Joe
 
Thanks @rconn
In TCC33, re-direction to tmp9: now works as it should.

Joe
 
Back
Top