[added 15.0.23] Run command, capture STDOUT

Ideas for new features & functions

Moderators: Dorian (MJT support), JRL

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

[added 15.0.23] Run command, capture STDOUT

Post by Grovkillen » Wed Dec 02, 2020 10:56 am

It would be really great if we could capture the STDOUT from a run command instead of having to rely on piping it to the clipboard or an external file. Something like this:

Code: Select all


Let>RP_CAPTURE_STDOUT=1
RunProgram>wmic path Win32_OperatingSystem get LastBootUpTime

//RP_STDOUT=20201202082216.500000+060

This incline that the RP_CAPTURE_STDOUT behaves like RP_WAIT=1 since we need to wait for the cmd to finish.

EDIT:
Since 15.0.23 this is working!

Code: Select all

Let>RP_CAPTURESTDOUT=1
RunProgram>wmic path Win32_OperatingSystem get LastBootUpTime
MDL>RP_STDOUT
Or more cleaned up:

Code: Select all

Let>RP_CAPTURESTDOUT=1
Let>RP_WINDOWMODE=0
RunProgram>wmic path Win32_OperatingSystem get LastBootUpTime
RegEx>[\S\s]*(\d{14}\.\d*\+\d*)[\S\s]*,RP_STDOUT,0,,,1,$1,LAST_BOOT_UP_TIME
MDL>LAST_BOOT_UP_TIME
Last edited by Grovkillen on Wed Jun 07, 2023 1:02 pm, edited 4 times in total.
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: Run command, capture STDOUT

Post by Grovkillen » Wed Apr 14, 2021 12:20 pm

Would this be considered to be added?
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: Run command, capture STDOUT

Post by Marcus Tettmar » Mon Apr 19, 2021 1:49 pm

Hi,

I have added this to the wish list for investigation.
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: Run command, capture STDOUT

Post by Grovkillen » Mon Apr 19, 2021 1:52 pm

Thanks for the feedback!
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: Run command, capture STDOUT

Post by Grovkillen » Sat Aug 14, 2021 1:49 pm

I'm currently coding a INI file handler which will support UTF8, delete (section/entry), timestamping of changes, concatinate value (front/back), timestamp to value, and a history log. It will be a terminal application. When requesting a value to be read or updated I want to be able to get this info straight from the command line and thus a capture of STDOUT would be awesome. *FINGERS CROSSED*
Let>ME=%Script%

Running: 15.0.27
version history

fightcancer
Macro Veteran
Posts: 250
Joined: Fri Apr 15, 2005 8:32 am

Re: Run command, capture STDOUT

Post by fightcancer » Tue Jan 04, 2022 8:23 pm

Seconding this request!

mightycpa
Automation Wizard
Posts: 343
Joined: Mon Jan 12, 2004 4:07 pm
Location: Vienna, VA

Re: Run command, capture STDOUT

Post by mightycpa » Sun Feb 12, 2023 9:46 pm

One more user that wants it!! That's over 300, by my count! :lol:
"A facility for quotation covers the absence of original thought." - Lord Peter Wimsey

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

Re: Run command, capture STDOUT

Post by Grovkillen » Thu Apr 06, 2023 4:47 am

I see more and more use of this enhancement suggestion. It's not ideal to have multiple scripts relying on the clipboard to get data and piping the output to files make the file system involved which will slow things down and involve more commands in MS. Please consider this request :)
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: Run command, capture STDOUT

Post by Grovkillen » Wed Jun 07, 2023 11:19 am

I found another use case for this:

Code: Select all

Let>RP_WAIT=1
Let>RP_WINDOWMODE=0
Let>PATH_TO_FILE=K:\SE\0D140\270001_Testkub.par
Let>CMD_TO_RUN=cmd /c c: & certutil -hashfile "%PATH_TO_FILE%" MD5 | clip
RunProgram>CMD_TO_RUN
GetClipBoard>HASH_OF_FILE,0
Let>CLEANUPT_REGEX=[\S\s]*([a-f0-9]{32})[\S\s]*
RegEx>CLEANUPT_REGEX,HASH_OF_FILE,0,,,1,$1,HASH_OF_FILE
MDL>HASH_OF_FILE
Instead of having to pipe it to a output file I would love to have it passed back into the script without the need for the clipboard. :D
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: Run command, capture STDOUT

Post by Marcus Tettmar » Wed Jun 07, 2023 11:44 am

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: Run command, capture STDOUT

Post by Grovkillen » Wed Jun 07, 2023 12:23 pm

OH!!!! HAPPY! :D :D :D :lol: :lol: :lol: :lol:
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: Run command, capture STDOUT

Post by Grovkillen » Wed Jun 07, 2023 12:28 pm

Updated now that this is live and working great :)

Code: Select all

Let>RP_WINDOWMODE=0
Let>RP_CAPTURESTDOUT=1
Let>PATH_TO_FILE=K:\SE\0D140\270001_Testkub.par
Let>CMD_TO_RUN=certutil -hashfile "%PATH_TO_FILE%" MD5
RunProgram>CMD_TO_RUN
Let>CLEANUP_REGEX=[\S\s]*([a-f0-9]{32})[\S\s]*
RegEx>CLEANUP_REGEX,RP_STDOUT,0,,,1,$1,HASH_OF_FILE
MDL>HASH_OF_FILE
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 07, 2023 4:01 pm

Sometimes you need to add cmd /c ahead of the command for it to return a result.
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 07, 2023 4:02 pm

Can someone confirm that this is working with RP_ADMIN=1?
Let>ME=%Script%

Running: 15.0.27
version history

User avatar
JRL
Automation Wizard
Posts: 3526
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Re: [added 15.0.23] Run command, capture STDOUT

Post by JRL » 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

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