1

I want to start a Kantu web macro from the command line on Mac. Essentially this is as simple as opening the Chrome or Firefox browser with a local HTML page (which contains the macro code). All works fine on Windows. But on macOS, when I use

mac:~ open 'file:////Users/fabrice/Kantu/demoautofill.html?direct=1&close=1&savelog=demotestlog.txt'

Chrome starts, and the file URL gets opened, but the '?direct=1&close=1&savelog=demotestlog.txt' GET parameter part is lost.

So the question is: How to launch a local html file with GET parameters?

I found this post: https://stackoverflow.com/questions/7710803/open-a-local-html-file-with-url-params-through-applescript which uses AppleScript as a workaround, but it is for Safari, I need Chrome. Plus I would like to avoid using AppleScript, if possible.

2

open just handles files, it doesn't know about GET parameters. So the AppleScript approach is probably the way to go here:

osascript -e 'tell application "Google Chrome" to 
    open location "file:///Users/YOU/path/to.html?foo=bar"'
  • open location is not a Google Chrome AppleScript command. It's part of the standard additions, therefore doesn't need to be inside a tell application block. open location will always open the URL in the system's default browser, regardless of any tell command. The way to open an URL using AppleScript in a specific browser is to tell application "Google Chrome" to tell the front window to make new tab with properties {URL:"scheme://host/path?query"} (assuming the front window exists, or creating it beforehand if not). – CJK Sep 21 '18 at 14:31
  • @cjk I have my default browser set to Safari, nevertheless the above snippet opens the page in Chrome. – nohillside Sep 21 '18 at 14:47
  • Fair enough, my mistake. That's not how it should work, but few things in AppleScript do. – CJK Sep 21 '18 at 14:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .