[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: 7395
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: 7395
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: 1131
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.27
version history

User avatar
Grovkillen
Automation Wizard
Posts: 1131
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.27
version history

User avatar
Grovkillen
Automation Wizard
Posts: 1131
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.27
version history

User avatar
Grovkillen
Automation Wizard
Posts: 1131
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.27
version history

User avatar
Grovkillen
Automation Wizard
Posts: 1131
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.27
version history

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
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: 1131
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.27
version history

User avatar
Grovkillen
Automation Wizard
Posts: 1131
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 » Tue Jan 16, 2024 12:26 pm

Marcus Tettmar wrote:
Wed Jun 14, 2023 8:17 am
Nothing is shared. There shouldn't be a clash.
Today the clash happened. A compile script crashed and was started up again. The crash happened during the run command and thus the "output.tmp" file was created in the ...AppData\Local\Temp folder. When the newly started script tried to do a RP_STDOUT read, the output file was locked, resulting in a new crash.

My suggestion is to not have this output.tmp file hardcoded but based on a GUID instead. This way there would be astronomical unlikely to have a clash.
Last edited by Grovkillen on Tue Jan 16, 2024 9:22 pm, edited 2 times in total.
Let>ME=%Script%

Running: 15.0.27
version history

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1390
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: [added 15.0.23] Run command, capture STDOUT

Post by Dorian (MJT support) » Tue Jan 16, 2024 12:37 pm

Have passed this on to dev.
Yes, we have a Custom Scripting Service. Message me or go here

User avatar
Grovkillen
Automation Wizard
Posts: 1131
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 » Fri Feb 02, 2024 7:21 pm

I just wonder if this is planned to be implemented or if I should not expect it to be addressed?
Let>ME=%Script%

Running: 15.0.27
version history

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
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 » Mon Feb 05, 2024 2:25 pm

I thought we had already done this and have just checked the source and see that, yes, indeed, the stdout file uses a UID. Perhaps we missed something off the release notes. The latest version is 15.0.24 so maybe it went in there. Can you please make sure you are running 15.0.24 and check again?
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: 1131
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 » Tue Feb 06, 2024 2:32 pm

I just updated and will wait and see. Sounds like it's fixed then :)

The update notes could be a tad more informative in this particular case, the "minor fixes" didn't sound too important for me to test :oops: :roll: :)
Let>ME=%Script%

Running: 15.0.27
version history

User avatar
Grovkillen
Automation Wizard
Posts: 1131
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 » Fri Feb 09, 2024 6:53 pm

I've been running the latest version for some days now and no crash yet. Thanks for the help. 8)
Let>ME=%Script%

Running: 15.0.27
version history

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