Here are the last two action condensations before the Executed Shell Script action below:
Prepend Text """ to Variable "Local_toOpen"
Append Variable "Local_toOpen" with Text """
i.e., surround the contents of the variable with double-quote marks.
The last action in the macro is Execute Shell Script:
open $KMVAR_Local_toOpen
The result: Execute a Shell Script failed with script error: The file /“/Applications/Thunderbird.app“ does not exist.
Where does that first slash come from? I put it to this honorable Court that since the last thing I did was prepend and append double-quotes, it did not come from me.
Since you haven't shown us your macro, it's hard to be sure if the macro contains the typo that I see in your question, but your question shows the wrong kind of double quotes. That's either a typo in your message or a typo in your macro.
So I just need to ask if you have smart quotes disabled in System Settings, in the following:
I was talking about the quotes in your error message:
If that was your error message, then your quotes may be the cause of your problem, which is why I was asking you to check something in System Settings.
I don't know anything about that, but I know there is a Share menu item in the Keyboard Maestro Editor under the File menu. It takes time to master, but there's where you find it.
I fixed the curly quotes. Dunno why the other double-quotes in my OP are straight. I like curly quotes for human consumption, when I'm not writing code. I hope turning them off in System Settings won't ruin my life.
Since you haven't shown us your macro, and since you seem to be implying that you have turned off the smart quotes, then the next step is to delete your action and recreate it. Hopefully then the correct quotes will be passed to the shell.
Or you can try to learn how to upload your macro so we can see it and troubleshoot faster.
Thanks. It takes me time to read someone else's macro. I'm still studying it. I see a small error, a double space before Excel. Not the main issue here though.
Don't do it this way -- put the quotes in the shell script action instead, so the script becomes:
open "$KMVAR_Local_toOpen"
The way you're doing it you are passing the path "/Applications/Safari.app" with the double-quotes as part of the actual path -- you're saying "start at the " directory". Because it isn't a valid absolute path (doesn't start with /), open will try to evaluate it in the context of the current working directory -- which for an "Execute a Shell Script" action is the root directory /.
That's where the extra / is coming from -- the error message is saying "starting at / I can't find the file "/Applications/Safari.app" because there's no directory named " in the root directory".
Also -- do you have a need for the shell script? You're spending resources unnecessarily and slowing things down -- it takes CPU cycles and time to instantiate then delete the shell -- and will cause you more problems than a simple:
Well, even if you stop using variables and just say: (using any app, I'm trying the app "Home")
It still gives you the error message. So the problem isn't with your variables, it's with your command.
Even if you don't use KM, and type that command directly into a Terminal window, you still get that error:
myname@MyNames-iMac ~ % open "/Applications/Home.app"
The file /Applications/Home.app does not exist.
So I guess the questions is now no longer about KM, but about how to use the open command. I'll let you look into that first, as the KM issue is no longer an issue.
By the way, you should not put Finder in that list, as it's not in the /Applications folder, at least not on my Mac.
The macro works with Thunderbird, but I get the "does not exist" error with Preview, both from the macro and manually in the terminal. Maybe the error occurs with Apple apps?
That's a theory. But until you can get the open command to work with Apple apps, your script won't work. I can't get it to work with Apple apps either.
But did you try Nige's suggestion to use the open action instead of the shell? What results did you get?