[added 15.0.23] Run command, capture STDOUT

Ideas for new features & functions

Moderators: Dorian (MJT support), JRL

User avatar
Marcus Tettmar
Site Admin
Posts: 7369
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Re: [added 15.0.23] Run command, capture STDOUT

Post by Marcus Tettmar » Wed Jun 07, 2023 4:20 pm

Grovkillen wrote:
Wed Jun 07, 2023 4:02 pm
Can someone confirm that this is working with RP_ADMIN=1?
It cannot work with RP_ADMIN=1 as it has to use a completely different mechanism. (as in, while you can set RP_ADMIN to 1 it will have no effect when using RP_CAPTURESTDOUT). There are likely lots of other caveats we have yet to discover and I suspect I will regret adding this command in about, oh, 20 minutes.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

User avatar
Marcus Tettmar
Site Admin
Posts: 7369
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Re: [added 15.0.23] Run command, capture STDOUT

Post by Marcus Tettmar » Wed Jun 07, 2023 5:04 pm

In any case, if you're not admin, and you start something as admin, then you won't have permission to interact with or access that process, so you won't be able to read its STDOUT. Makes no sense. Hence you can't use RP_ADMIN here.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

User avatar
Grovkillen
Automation Wizard
Posts: 940
Joined: Fri Aug 10, 2012 2:38 pm
Location: Bräcke, Sweden
Contact:

Re: [added 15.0.23] Run command, capture STDOUT

Post by Grovkillen » Thu Jun 08, 2023 5:04 am

Understood, and no need to regret it. If it's documented it's all good :)
Let>ME=%Script%

Running: 15.0.23
version history

User avatar
Grovkillen
Automation Wizard
Posts: 940
Joined: Fri Aug 10, 2012 2:38 pm
Location: Bräcke, Sweden
Contact:

Re: [added 15.0.23] Run command, capture STDOUT

Post by Grovkillen » Thu Jun 08, 2023 5:13 am

JRL wrote:
Wed Jun 07, 2023 4:15 pm
This works for me:
(Note the use of "Between>" rather than "RegEx>")
Looks like your file is on a shared drive, be sure your admin user has access to the share.

Code: Select all

Let>PATH_TO_FILE=L:\A\Run MyTime.exe

Let>RP_WINDOWMODE=0
Let>RP_CAPTURESTDOUT=1
Let>RP_Admin=1

Let>CMD_TO_RUN=cmd /c certutil -hashfile "%PATH_TO_FILE%" MD5
RunProgram>CMD_TO_RUN
Between>RP_STDOUT,:%crlf%,%crlf%Cert,HASH_OF_FILE,Match_Num
MDL>HASH_OF_FILE_1
My code did work I just added it as a information for others that use the CAPTURESTDOUT. And sometimes you need to terminate the cmd.exe by using the /c switch. I love this feature and are testing it like a mad man to see how it behaves :)
Let>ME=%Script%

Running: 15.0.23
version history

User avatar
Grovkillen
Automation Wizard
Posts: 940
Joined: Fri Aug 10, 2012 2:38 pm
Location: Bräcke, Sweden
Contact:

Re: [added 15.0.23] Run command, capture STDOUT

Post by Grovkillen » Thu Jun 08, 2023 8:21 am

Maybe just add this to the help:
RP_CAPTURESTDOUT=1 will allow for a capture of the output from a cmd command but beware that you cannot use this together with RP_ADMIN=1 (if set to 1 it will be ignored when RP_CAPTURESTDOUT=1). Also be aware that some commands will output in sessions meaning that not everything might be capture by the RP_CAPTURESTDOUT=1, in that case you should use either a pipe to clipboard or direct the output to an external file. In some cases it will be of help to use the "cmd /c" switch to force the command to terminate and reveal an output. It's a test by case type of deal.
Let>ME=%Script%

Running: 15.0.23
version history

User avatar
Grovkillen
Automation Wizard
Posts: 940
Joined: Fri Aug 10, 2012 2:38 pm
Location: Bräcke, Sweden
Contact:

Re: [added 15.0.23] Run command, capture STDOUT

Post by Grovkillen » Thu Jun 08, 2023 1:49 pm

Is this RP_STDOUT variable fetched from a temp file in local data? If so, it needs to be unique (name) because if multiple applications use the capture at the same time the exact same issue as with using clipboard will arise.
Let>ME=%Script%

Running: 15.0.23
version history

User avatar
Grovkillen
Automation Wizard
Posts: 940
Joined: Fri Aug 10, 2012 2:38 pm
Location: Bräcke, Sweden
Contact:

Re: [added 15.0.23] Run command, capture STDOUT

Post by Grovkillen » Wed Jun 14, 2023 7:20 am

Marcus, is my observation true? Can this be a problem?
Let>ME=%Script%

Running: 15.0.23
version history

User avatar
Marcus Tettmar
Site Admin
Posts: 7369
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Re: [added 15.0.23] Run command, capture STDOUT

Post by Marcus Tettmar » Wed Jun 14, 2023 8:17 am

Nothing is shared. There shouldn't be a clash.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

User avatar
Grovkillen
Automation Wizard
Posts: 940
Joined: Fri Aug 10, 2012 2:38 pm
Location: Bräcke, Sweden
Contact:

Re: [added 15.0.23] Run command, capture STDOUT

Post by Grovkillen » Wed Jun 14, 2023 10:46 am

Ok, thanks for the information. Then my findings must be caused by something else but at least I can rule this thesis out of the equation :)
Let>ME=%Script%

Running: 15.0.23
version history

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts