Running a shell script
-
@Dan-Korneff tell me how! :D
-
@tomekslesicki I think something like this:
#!/bin/zsh osascript <<EOF do shell script "rm -rf '/Library/Audio/Plug-Ins/Components/Plugin.component'; rm -rf '/Library/Audio/Plug-Ins/VST3/Plugin.vst3'" with administrator privileges EOF killall Terminal
with administrator privileges will pop up the password dialog
-
@Dan-Korneff thanks! What extension should I save this under?
-
@tomekslesicki Use the .sh extension and then chmod +x on the file so it's executable.
-
@Dan-Korneff it still opens in XCode here becuase it's set as the default app for .sh files.
@d-healey I found your older post about this where you suggested using:
const oc = FileSystem.fromAbsolutePath("/usr/bin/open");
and then:
oc.startAsProcess(bashScript);
But the problem is I can't figure out the path to shell using this method.
-
@tomekslesicki said in Running a shell script:
I can't figure out the path to shell
You can type
which bash
into the terminal and it will give you the path. -
@d-healey thanks! It should then be
const oc = FileSystem.fromAbsolutePath("/bin/bash");
but it doesn't open the script then.
-
@tomekslesicki said in Running a shell script:
it still opens in XCode here becuase it's set as the default app for .sh files.
Ahh.. I see. Well, you have 2 options with that. #1 is to change the extension.
I think the .command will automatically open terminal.The other option is to use tell application "Terminal" which would activate the Terminal and run your script:
https://superuser.com/questions/195633/applescript-to-open-a-new-terminal-window-in-current-spaceI haven't done that before, but here's what GPT says:
Force Terminal to launch and execute the script by explicitly passing the shell command to Terminal.app: #!/bin/zsh osascript <<EOF tell application "Terminal" activate do script "zsh '${PWD}/DeletePlugin.sh'" end tell EOF This launches Terminal, activates it, and runs your script using zsh, ignoring file type associations
-
@Dan-Korneff said in Running a shell script:
The other option is to use tell application "Terminal" which would activate the Terminal and run your script:
But this is within the script, so won't trigger until the script is running, which will already be in xcode.
-
@tomekslesicki said in Running a shell script:
but it doesn't open the script then.
What are you passing to startAsProcess?
-
@Dan-Korneff Thank you, changing the extension to .command works like a charm!
-
@Dan-Korneff said in Running a shell script:
I think the .command will automatically open terminal.
Seriously ? I searched for hours and GPT couldn't say more than "use Automator to start the shell automatically..."
Your're the man