How to retrieve information from Bash or CMD

Share your favorite FastKeys commands
Post Reply
joachim.weyl
Posts: 1
Joined: Feb 21st, ’17, 17:05

Post by joachim.weyl » Feb 21st, ’17, 17:08

How would one read in CMD and Bash output to then put through a regular expression and do some conditional testing on?
User avatar
Marko
Posts: 1051
Joined: Mar 2nd, ’13, 21:02

Post by Marko » Feb 22nd, ’17, 00:03

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
lehmakommionu
Posts: 34
Joined: Aug 2nd, ’14, 20:50

Post by lehmakommionu » Apr 2nd, ’17, 23:32

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
Post Reply