HISE Logo Forum
    • Categories
    • Register
    • Login

    Running a shell script

    Scheduled Pinned Locked Moved Scripting
    17 Posts 4 Posters 449 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Dan KorneffD
      Dan Korneff @tomekslesicki
      last edited by

      @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 - Producer / Mixer / Audio Nerd

      T 1 Reply Last reply Reply Quote 0
      • T
        tomekslesicki @Dan Korneff
        last edited by

        @Dan-Korneff thanks! What extension should I save this under?

        Dan KorneffD 1 Reply Last reply Reply Quote 0
        • Dan KorneffD
          Dan Korneff @tomekslesicki
          last edited by Dan Korneff

          @tomekslesicki Use the .sh extension and then chmod +x on the file so it's executable.

          Dan Korneff - Producer / Mixer / Audio Nerd

          T 1 Reply Last reply Reply Quote 0
          • T
            tomekslesicki @Dan Korneff
            last edited by

            @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.

            d.healeyD Dan KorneffD 2 Replies Last reply Reply Quote 0
            • d.healeyD
              d.healey @tomekslesicki
              last edited by

              @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.

              Libre Wave - Freedom respecting instruments and effects
              My Patreon - HISE tutorials
              YouTube Channel - Public HISE tutorials

              T 1 Reply Last reply Reply Quote 0
              • T
                tomekslesicki @d.healey
                last edited by

                @d-healey thanks! It should then be

                const oc = FileSystem.fromAbsolutePath("/bin/bash");
                

                but it doesn't open the script then.

                d.healeyD 1 Reply Last reply Reply Quote 0
                • Dan KorneffD
                  Dan Korneff @tomekslesicki
                  last edited by

                  @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-space

                  I 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 - Producer / Mixer / Audio Nerd

                  d.healeyD T ustkU 3 Replies Last reply Reply Quote 1
                  • d.healeyD
                    d.healey @Dan Korneff
                    last edited by

                    @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.

                    Libre Wave - Freedom respecting instruments and effects
                    My Patreon - HISE tutorials
                    YouTube Channel - Public HISE tutorials

                    1 Reply Last reply Reply Quote 1
                    • d.healeyD
                      d.healey @tomekslesicki
                      last edited by

                      @tomekslesicki said in Running a shell script:

                      but it doesn't open the script then.

                      What are you passing to startAsProcess?

                      Libre Wave - Freedom respecting instruments and effects
                      My Patreon - HISE tutorials
                      YouTube Channel - Public HISE tutorials

                      1 Reply Last reply Reply Quote 0
                      • T
                        tomekslesicki @Dan Korneff
                        last edited by

                        @Dan-Korneff Thank you, changing the extension to .command works like a charm!

                        1 Reply Last reply Reply Quote 2
                        • ustkU
                          ustk @Dan Korneff
                          last edited by

                          @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 👍

                          Can't help pressing F5 in the forum...

                          1 Reply Last reply Reply Quote 1
                          • First post
                            Last post

                          21

                          Online

                          1.8k

                          Users

                          11.9k

                          Topics

                          104.0k

                          Posts