My comments to your macro after short analysis:
- You want to run potentially more than one window with parallel jobs which zipping files from different catalogs (loop over selection from Finder). It will be hard to trace status of all windows in the same time - you can trap in practice only one output in time in KM. The solution presented here: Run command in Terminal.app window Macro (v11.0.4) assume, that only one terminal window is running asynchronously and KM will wait for the results from that one instance. Solution for multiple child windows requires different way.
- Window doesn't close because it is NOT TERMINAL WINDOW but KM window with results (after finishing the task - no progres in result, because job was already finished)
- To observe what's happens you need real terminal window which should be triggered by f.ex. AppleScript (see below) and transfer to it command to execute (with arguments). But it means that such window will stay open after finishing script unless you finish the script with exit (or add exit after name of the script). In that case you will see the progres but loose window after script finish (you can add small delay using sleep before exit).
Example code to instance Terminal window:
-- KMINSTANCE is part of created window name
set kmInst to system attribute "KMINSTANCE"
-- Get KM variable with KMFIFO node name/path
tell application "Keyboard Maestro Engine"
set localFile to getvariable "LOCALFILE" instance kmInst
set localFilePath to getvariable "LOCALFILEPATH" instance kmInst
set localFileName to getvariable "LOCALFILENAME" instance kmInst
set localBaseName to getvariable "LOCALBASENAME" instance kmInst
set destDir to getvariable "DEST_DIR" instance kmInst
set out to destDir & localBaseName & ".zip"
end tell
-- after finishing jobs wait 10 seconds
set exitcmd to "; sleep 10; exit"
-- uncomment below to see results (window will not close)
-- set exitcmd to ""
tell application "Terminal"
activate
-- "exit" command after 1st command will close the window
set result to do script "~/Documents/kmmacros/Forum/parazip.sh " & localFile & " " & out & exitcmd
--set result to do script "echo " & kmfifo in theTab
return result
end tell
Below my proposal - variant with windows showing progress and closing after 10 seconds since process finished.
Archive to the second Pane.kmmacros (6.2 KB)
