4 Replies Latest reply on Sep 16, 2009 8:47 AM by Tols (UK)

    shell command - making Director continue whilst shell takes place

    Tols (UK)

      Hi

       

      a quick question on Shelling -

       

      on a pc if i use Buddy API to Shell a command or run a bat file then i can have the Director app continue whilst the utility that I called takes place.

      However, that function doesn't work on the mac

       

      so i use Valentin Schmidt's shell.xtra

       

      which is great, and also seems to have a Callback function so I'd imagine that it allows for things to continue whilst the shell command takes place.

       

      But it doesn't seem to at least not when I try to create a disk image with the hdiutil command

      eg.

      tscript="echo -n $pw | hdiutil create -srcfolder '$src' -encryption -stdinpass -fs HFS+ -volname '$imagename' '$destimage'"

      shell_cmd(tscript)

       

      Since creating a disk image can take a while I'd rather Director continue and then I can at least monitor the size of the image as its created. Or let the user get on with using the app.

      At the moment Director is just frozen and if the image is large enough (eg 4GB) then it freezes entirely and needs a force quit.

       

      Has anyone had any experience of this?

       

      Presumably another option might be to write a script with the appropriate extension (like a bat file in Windows) and then open it with the open... with... command (beacuse then its running outside of Director) but I thought I'd try the neater method first.

       

      Thanks

        • 1. Re: shell command - making Director continue whilst shell takes place
          Mike Blaustein Level 4

          I have not used it on Mac, but I believe that Valentin's shellxtra has an asynchronous version:

           

          shell_cmd_asynch

           

          That should start the shell command then let Director continue while it processes.

          • 2. Re: shell command - making Director continue whilst shell takes place
            Tols (UK) Level 1

            Hi Mike

             

            yes, asynchronous is what I'm after!

             

            unfortunately that asynch cmd (i've just looked at the windows readme and its called shell_cmd_thread) doesn't seem to be available in the Mac version. (v05, ie for Dir 11, which is I think the latest)

             

             

            all i get (according to the readme) is

             

            ***************************************************************

            INTERFACE

            ***************************************************************

             

            *shell_cmd string, *

            *shell_cmd_list string

             

            -- Utilities for path conversion

            *shell_hfs2posix string

            *shell_posix2hfs string

            He doesn't list it as a difference to the Win version but I've tried shell_cmd_asynch and I've tried shell_cmd_thread and that handler isn't defined on the mac.
            Thanks for the tip anyway. i will go down the batch file route, whatever that may be on a mac...

            • 3. Re: shell command - making Director continue whilst shell takes place
              Mike Blaustein Level 4

              On a Mac, there are no batch files, but you can do quite a lot of automation with Applescript.  That would be the approach I would take.  Also, you might want to email Valentin (his address is in the readme for the xtra, I think) and ask if he has a newer version with asynchronous functions.  He is very friendly and will often help if he can.

              1 person found this helpful
              • 4. Re: shell command - making Director continue whilst shell takes place
                Tols (UK) Level 1

                so, you were right - Valentin had the answer:

                 

                 

                unfortunately there is no mac version of shell xtra that supports
                multithreading/asynchronous mode, simply because I couldn't find any
                decent way to implement this on the mac.

                 

                but if you don't need intermediate STDOUT/STDERR feedback, it's no
                problem to start a process that operates in the back without freezing
                director, by putting ">/dev/null &" at the end of your command string.

                 

                 

                which works perfectly fine for me.

                 

                he went on to suggest you can

                 

                occasionally check (with synchronous shell xtra executions and the

                system's "ps" command + apropriate parameters) if the corresponding
                process has finished or is still running.

                 

                Disco.