How to retrieve information from Bash or CMD

Share your favorite FastKeys commands
Posts: 1
Joined: Tue Feb 21, 2017 5:05 pm

How to retrieve information from Bash or CMD

PostPosted by joachim.weyl » Tue Feb 21, 2017 5:08 pm

How would one read in CMD and Bash output to then put through a regular expression and do some conditional testing on?

Site Admin
User avatar
Posts: 641
Joined: Sat Mar 02, 2013 9:02 pm

Re: How to retrieve information from Bash or CMD

PostPosted by Marko » Wed Feb 22, 2017 12:03 am

Here is one example using AutoHotkey command syntax:
Code: Select all
RunWait %comspec% /c dir > C:\My Temp File.txt
FileRead, VarToContainContents, C:\My Temp File.txt
FileDelete, C:\My Temp File.txt
MsgBox % VarToContainContents

What exactly are trying to do?
More information: https://www.autohotkey.com/docs/FAQ.htm#output

Posts: 34
Joined: Sat Aug 02, 2014 7:50 pm

Re: How to retrieve information from Bash or CMD

PostPosted by lehmakommionu » Sun Apr 02, 2017 10:32 pm

with the following example you can also get by without writing output to a file but the disadvantage is that the cmd.exe pops up for a second, so I personally prefer the option Marko provided earlier, where the cmd window can be hidden.

Code: Select all
FilePath=C:\test.jpg   
objShell := ComObjCreate("WScript.Shell")
objExec := objShell.Exec(ComSpec " /c C:\Users\Username\Documents\FastKeys\exiftool.exe -XPKeywords " FilePath)    ;Get the Tags/Keywords of the Image File
strStdOut := ""
while, !objExec.StdOut.AtEndOfStream
    strStdOut := objExec.StdOut.ReadAll()
MsgBox %strStdOut%
return


to hide the cmd window
Code: Select all
Runwait, %comspec% /c C:\Users\username\Documents\FastKeys\exiftool.exe -XPKeywords "%FilePath%" > C:\Users\Username\Documents\FastKeys\temp_tags.txt, , Hide   ;Write the Image Tags/Keywords Temporarily to a File

Return to User Commands and Scripts

Who is online

Users browsing this forum: No registered users and 1 guest