Welcome!

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

SignUp Now!

TEE in @EXECARRAY in a library function?

May
12,846
164
This works on a command line.

Code:
echo %@execarray[a,cscript //NoLogo u:\vbs\tlhelper.vbs | tee t:\execarray.tmp]

If I do this in a library function

Code:
if %@execarray[s,cscript //NoLogo %vbsfile | tee t:\tl_execarray.tmp] != 0 (echo cscript error & goto done)

I get an error.

Code:
TCC: tl [75]  Syntax error "@execarray[s,cscript"

If I escape the pipe and do this

Code:
if %@execarray[s,cscript //NoLogo %vbsfile ^| tee t:\tl_execarray.tmp] != 0 (echo cscript error & goto done)

the library function works as expected except that I get this in t:\.

Code:
2023-04-12  13:13               0  tl_execarray.tmp]

Any ideas on getting it to work?
 
Code for test.vbs;
Code:
For kount = 1 To 10
  WScript.Echo "Element: " & kount
Next

Code for library;
Code:
R:\>library /f test
vince.library$test {
@setlocal
@echo off
setarray s[10]
cscript //nologo test.vbs > clip9:
if exist r:\tl_execarray.tmp del /q r:\tl_execarray.tmp
set ExitCode=%@execarray[s,type clip9: | tee r:\tl_execarray.tmp]
echo _execarray: %_execarray
iff %ExitCode eq 0 then
echo.
echo            Total Number of Dimensions: %@arrayinfo[s,0]
echo Number of Elements in First Dimension: %@arrayinfo[s,1]
echo              Total Number of Elements: %@arrayinfo[s,5]
echo %s[0], %s[1]
unsetarray s
if exist r:\tl_execarray.tmp type r:\tl_execarray.tmp
else
echo An error occured.
endiff
}

Results;
Code:
R:\>which test
test is a library function

R:\>test
_execarray: 10

           Total Number of Dimensions: 1
Number of Elements in First Dimension: 10
             Total Number of Elements: 10
Element: 1, Element: 2
Element: 1
Element: 2
Element: 3
Element: 4
Element: 5
Element: 6
Element: 7
Element: 8
Element: 9
Element: 10

Joe
 
What's your point ... that it works if you don't put the CSCRIPT command inside the @EXECARRAY? Maybe that pipe is problematic when attached to an external as opposed to an internal (?). Did you try it with CSCRIPT inside @EXECARRAY?

Using a file, I could just cscript > the_file and then setarray /r the_file array_name. And since the result is already in a file I wouldn't have to TEE anything.
 
Yes, I tried it with CScript inside of @EXECARRAY;
Code:
R:\>library /f test
vince.library$test {
@setlocal
@echo off
setarray s[10]
if exist r:\tl_execarray.tmp del /q r:\tl_execarray.tmp
set ExitCode=%@execarray[s,cscript //nologo test.vbs | tee r:\tl_execarray.tmp]
echo _execarray: %_execarray
iff %ExitCode eq 0 then
echo.
echo            Total Number of Dimensions: %@arrayinfo[s,0]
echo Number of Elements in First Dimension: %@arrayinfo[s,1]
echo              Total Number of Elements: %@arrayinfo[s,5]
echo %s[0], %s[1]
unsetarray s
if exist r:\tl_execarray.tmp type r:\tl_execarray.tmp
else
echo An error occurred.
endif
}

It works here as it should.
Code:
R:\>test
_execarray: 10

           Total Number of Dimensions: 1
Number of Elements in First Dimension: 10
             Total Number of Elements: 10
Element: 1, Element: 2
Element: 1
Element: 2
Element: 3
Element: 4
Element: 5
Element: 6
Element: 7
Element: 8
Element: 9
Element: 10

I just prefer running the CScript by itself, not from within a function.

Less problems when debugging.

Joe
 
What does;
Code:
echo %_expansion
...return?

Maybe Setdos is causing some problems?

Joe
 
On my system,
Code:
setdos /X-5
causes problems with the pipe.

That is, tee is not executed, and the r:\tl_execarray.tmp file is not created.

Joe
 
I'm not using SETDOS. The script just outputs records like this, one for each service. There are no funky characters in the output.

Code:
AppXSvc
5096
AppX Deployment Service (AppXSVC)
20230412170759.618593-240
156250
156250
12324864

Sending the script output to a file and using SETARRAY /R works nicely.
 

Similar threads

Back
Top