• Login
sketchucation logo sketchucation
  • Login
⚠️ Libfredo 15.4b | Minor release with bugfixes and improvements Update

How to launch applications on Mac with Ruby?

Scheduled Pinned Locked Moved Developers' Forum
10 Posts 4 Posters 461 Views 4 Watching
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.
  • W Offline
    Whaat
    last edited by 27 Apr 2009, 13:51

    Hi,

    On PC, I am using UI.openURL(file_path) to open an application or run a batch file. This does not seem to work on Mac. Or does it? How do you launch an application on a Mac with Ruby?

    Also, can you create and run a batch file on a Mac? Does Mac have something equivalent to batch files?

    Thanks!

    SketchUp Plugins for Professionals

    1 Reply Last reply Reply Quote 0
    • T Offline
      tomasz
      last edited by 27 Apr 2009, 14:11

      Hi Whaat,
      There was a thread dedicated to this issue.

      In SU2KT I do it this way:

      @unknownuser said:

      Thread.new do
      system(command options)
      end

      I though it will allow KT to run without freezing the SU, but it works only for very limited time.

      I hope we can find proper way to do it on both systems.

      Tomasz

      Author of [Thea Render for SketchUp](http://www.thearender.com/sketchup)

      1 Reply Last reply Reply Quote 0
      • A Offline
        AdamB
        last edited by 27 Apr 2009, 16:29

        Ha. I find totally the opposite so in LightUp I have to do:

        UI.openURL("file;//" + File.expand_path(filepath)) if filepath and not(PLATFORM.include? "mswin")
        
        

        On (my test) PC, it just crashes.

        Un*x systems have very flexible 'batch files'. They can be arbitrary languages too but adding a line at the beginning of the batch file. Starting with:

        #!/bin/bash
        
        

        means run this batch file using this flavor of shell (aka Cmd.exe in Win32)

        Developer of LightUp Click for website

        1 Reply Last reply Reply Quote 0
        • W Offline
          Whaat
          last edited by 27 Apr 2009, 17:12

          @adamb said:

          Ha. I find totally the opposite so in LightUp I have to do:

          UI.openURL("file;//" + File.expand_path(filepath)) if filepath and not(PLATFORM.include? "mswin")
          > 
          

          So this works to open an App or file on a Mac? (I can't test right now)

          SketchUp Plugins for Professionals

          1 Reply Last reply Reply Quote 0
          • W Offline
            Whaat
            last edited by 27 Apr 2009, 17:15

            @unknownuser said:

            Hi Whaat,
            There was a thread dedicated to this issue.

            In SU2KT I do it this way:

            @unknownuser said:

            Thread.new do
              system(`command options`)
            end
            

            I though it will allow KT to run without freezing the SU, but it works only for very limited time.

            I hope we can find proper way to do it on both systems.

            Tomasz

            Thank Tomasz, I am aware of the thread but I did not see a solution that worked with Mac. I am able to launch Indigo with parameters using a batch file on a PC (the command window closes after execution) but I am trying to figure out how to do the equivalent on a Mac

            SketchUp Plugins for Professionals

            1 Reply Last reply Reply Quote 0
            • T Offline
              tomasz
              last edited by 1 May 2009, 15:51

              @whaat said:

              [I am aware of the thread but I did not see a solution that worked with Mac.

              I thought that

              system(`command options`)
              

              works fine on Mac. At least I have had such an impression from posts from Mac users on KT forum.
              Unfortunately I have no Mac available to test it on my own.
              The method will probably block SU on MAC, so it is not a perfect solution anyway.

              Tomasz

              Author of [Thea Render for SketchUp](http://www.thearender.com/sketchup)

              1 Reply Last reply Reply Quote 0
              • A Offline
                AdamB
                last edited by 6 May 2009, 19:52

                @whaat said:

                @adamb said:

                Ha. I find totally the opposite so in LightUp I have to do:

                UI.openURL("file;//" + File.expand_path(filepath)) if filepath and not(PLATFORM.include? "mswin")
                > > 
                

                So this works to open an App or file on a Mac? (I can't test right now)

                OK, it looks like PC just can't handle being given a scheme handler. If you just give the path on PC it works fine. On the Mac, it (correctly in my book) expects a scheme handler for the URL.

                Adam

                Developer of LightUp Click for website

                1 Reply Last reply Reply Quote 0
                • TIGT Offline
                  TIG Moderator
                  last edited by 6 May 2009, 21:50

                  UI.openURL("file;//" + File.expand_path(filepath))
                  

                  works fine on a PC, if 'filepath' points to either an exe-file ora file-type... I don't see the issue ?
                  If you want to open a file with a particular app on a PC use a WinScript socket...

                  TIG

                  1 Reply Last reply Reply Quote 0
                  • A Offline
                    AdamB
                    last edited by 6 May 2009, 22:39

                    Not on my WinXP laptop. Just crashes.

                    Developer of LightUp Click for website

                    1 Reply Last reply Reply Quote 0
                    • TIGT Offline
                      TIG Moderator
                      last edited by 7 May 2009, 07:43

                      Works fine on my PC with Vista. Opens an app (.exe) or a file with it's assigned app...
                      Puzzling...

                      TIG

                      1 Reply Last reply Reply Quote 0
                      • 1 / 1
                      1 / 1
                      • First post
                        1/10
                        Last post
                      Buy SketchPlus
                      Buy SUbD
                      Buy WrapR
                      Buy eBook
                      Buy Modelur
                      Buy Vertex Tools
                      Buy SketchCuisine
                      Buy FormFonts

                      Advertisement