Welcome!

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

SignUp Now!

Using @PSHELL from @EVAL

Aug
1,915
68
Code:
     _x64: 1
   _admin: 1
_elevated: 1

TCC  26.00.29 x64   Windows 10 [Version 10.0.18362.719]

Code:
echo %@pshell[100+1]
returns 101, which is correct.

Code:
echo %@len[%@pshell[100+1]]
returns 5, instead of 3.

Code:
echo %@eval[%@pshell[100+1]]
returns
Code:
TCC: Syntax error "101
"

If I store the result in an environment variable;
Code:
set result=%@pshell[100+1]
and then;
Code:
echo %@eval[%result]
it returns 101, which is correct.

Why can I not use the @pshell function directly from @eval?

Joe
 
Code:
echo %@eval[%@execstr[pshell /s 100+1]]
returns 101, which is correct, but use of @pshell desired.

Joe
 
Have you tried passing @PSHELL's output to @ASCII?

I'm ignorant of @PSHELL, but offhand it looks as if you might be getting a CR/LF in there.
 
You are correct @Charles Dye

Code:
e:\utils>echo %@ascii[%@pshell[100+1]]
49 48 49 13 10

I'll leave it for @rconn to explain why this is happening.

Joe
 
There's a newline in there!

Code:
v:\> echo **%@pshell[100+1]**
**101
**
 
Okay, so this is kind of inelegant:
Code:
C:\>echo "%@rtrim["%@char[10 13]",%@pshell[100+1]]"
"101"

C:\>
 
I came up with this;
Code:
function pshell64=`%@strip[%@char[13 10],%@pshell[%$]]`
which works.

However, I think I'll go with what @Charles Dye provided;
Code:
function pshell64=`%@rtrim["%@char[10 13]",%@pshell[%$]]`

Bummer that I have to use a user-defined @pshell64 function instead of @pshell, but as the PowerShell DLL is a third-party tool, this appears to be a workable solution.

Thanks from Joe
 

Similar threads

Back
Top