Wait for process before continuing script

Hey there,
Just been working on this for a bit now in script editor. I'm still really new to the script editor functions, but would like some direction. If automater is a alternative then please help me understand how to make it work with that.
Otherwise all help is greatly appreciated!
Goal of the script:
1) load disk image. (This works)
2) open application requiring disk image. (This works)
3) Check to see in app process is running: running --> wait till it is not, when not running --> eject above disk image
Code:
tell application "Finder" -- Note when using tell Finder it gives can't get running of process
          if process "App Process" is not running then
                    set bootDisk to name of startup disk
                    set otherDisks to every disk whose (name is not bootDisk) and (name is not "iTunes") and (name is not "Applications") and (name is not "BOOTCAMP")
                    repeat with myDisk in otherDisks
                              try
  eject myDisk -- When using tell System Events it give Expected end of line but found identifier on line.
                              end try
                    end repeat
          end if
end tell
Another: Oddly the script will run the app, it throws the error while running, but the app still runs. The disk Image is also gone.
Thanks again for any helpful comments and direction.
-- Josh

Okay, Neil and tw^3, thanks you for your help, I got the effect I wanted cleaned up the code a smidge.
Code:
tell application "Finder"
          open document file "DiskImage" of folder "GAMES" of disk "Applications"
    delay 2 & close every window
          open application file "App" of folder "Myth2" of folder "GAMES" of disk "Applications"
end tell
delay 4.5
tell application "System Events"
          repeat
                         if not (exists process "process") then
                                        if exists "DiskName" then
                                                       do shell script "hdiutil detach \"/Volumes/DiskName\""
                  error number -128 --
            end if
                         end if
       if exists (process "process") then
       end if
       delay 10
          end repeat
end tell
Last little question about what I have, in the if statement checking if the process does not exist anymore, I put quit after the shell script to eject. but it would just hang there. Would it be better to do a repeat while? or would you just user cancel (error -128) the script from executing like I have it.
-Josh
EDIT: made it work better, used a repeat while... and moved the if not exists after the repeat...
repeat while exists "app process"
end repeat
if not (exists process "app process")
......blah blah code code
end if

Similar Messages

  • Text Entry not waiting for entry before continuing

    Captivate 4
    I'm trying to add a TEB where the user will need to enter the correct text before moving to the next slide.  I would like it to continue as soon as they user types the correct entry.  The problem is that the slide doesn't pause to wait for the entry - it continues to the next slide without anything being typed or a click.  ??
    I have the correct text listed in the 'Correct Entries' box and have it set to 'go to next slide' for 'On success'.  Under 'Options', I have it set to 'Validate User Input'.  I do not have any hint or caption buttons, and I am not showing a 'submit' button.
    Can someone tell me how to get it to pause the training to wait for the user to enter the correct text?
    Screen shots below.
    Thanks in advance,
    D

    Hi there
    Indeed there is!
    You enable the Button in the properties. This will place an associated button next to the field.
    What's that you are asking? You don't want a button?
    Well, nobody said you actually have to SEE the button! Just double-click the button and its properties will show. Choose Transparent Button and configure it so it's invisible. Then you configure the other "1" for the Button press!
    Cheers... Rick
    Helpful and Handy Links
    Captivate Wish Form/Bug Reporting Form
    Adobe Certified Captivate Training
    SorcerStone Blog
    Captivate eBooks

  • TS4057 I did this and now my videos are not working. They show the pictures aren't there on some and on others it shows they are there, but doesn't show them in the player. When I try to Share anything it just says Waiting for Processing for hours. What d

    I did this and now my videos are not working. They show the pictures aren't there on some and on others it shows they are there, but doesn't show them in the player. When I try to Share anything it just says Waiting for Processing for hours. What do I do?
    I also got Motion and can't figure out how to use it with Final Cut Pro X. Any help woud be great. Thanks

    I have no idea what may have caused your MacBook to stop working, but from your description it kind of sounds like it may have started before you ran Software Update and installed the new Apps. Just the general slow feeling and bugginess is what tips me off. You said that you weren't sure if you had closed all open windows, that doesn't matter if the computer restarts itself. It automatically closes all other open applications when restarting.
    As to your data being retrievable, if when you take it in they do a fresh install of the OS, then no, it will not be unless you want to pay several thousand dollars to a software retrieval company.
    I am glad to hear that you have taken into the Apple Store to get it fixed, and that you have all of your purchased music backed up to your iPod. You should be able to just transfer it all back to iTunes once you get your computer back should it be necessary.
    As a side note, the proper place for this topic would probably in the MacBook forums, not iTunes since there is no evidence that iTunes started the issue.

  • Failed to wait for process condition: errno(22).

    Hello,
    I am experiencing some failures with FMS 3.5.1.
    Searched the logs and it appears the following error repeats itself more than 20 times per second in the admin logs:
    Failed to wait for process condition: errno(22).
    Can anyone offer some info on this error ?
    Thanks

    check that:
    http://kb2.adobe.com/cps/407/kb407245.html

  • SSIS wait for file to continue

    I know this question has been asked a dozen times. How do I get SSIS to wait for the existence of a file before continuing the package.  I know countless people have pointed to FileWatcher Task, unfortunately we are not allowed to install third party
    software on client servers/machines.  I've read about doing a loop using script task but also read that doing Thread.Sleep is a horrible idea. My SSIS package extracts data into a text file where it is processed by a program and put into another text
    file. I need to wait for that text file to show up before I can continue with my package.  Can someone offer some suggestions?

    Have a Windows Service using
    FileSystemWatcher to monitor for file arrivals, the very Windows Service will trigger your package upon a file arrival. It is better to actually just record the file in a schedule table to process if you expect a large number of large files to arrive fast,
    the package would pick next from the table.
    Arthur My Blog

  • Wait for a "do shell script" command to finish

    i have an applescript that has to call a few external applications. i currently do this by setting the exact syntax of the external command in a string variable, then issue a "do shell script cmd" (seen many examples across the net using this standard)
    my applescript continues beyond these commands. how do i set the applescript to either wait for the above external command to finish, or not?
    regards
    jingo_man

    Usually AppleScript will wait for a shell script to complete before it continues, but adding an ampersand (&) at the end of the shell script command will make it run in the background, which allows the AppleScript to continue. See Technical Note 2065: do shell script in AppleScript for more information.

  • Exchange mode- mail wait for minutes before the app sends out mails

    Guys I have a company email address when I was going with POP everything was perfect.
    But IT guys forced me to go with exchange I thought it should be ok too, but I can bear anything else only thing which is very difficult to understand.
    When I send out an email, no matter is it big or just few letters, the mail app will put it there and wait for so long, then it will start to send it out.
    I don't know what is the reason, why it is designed like this??? Any thing that I need to configure even I have done checking everything I can find.
    Thank you!

    Even it is by imap of gmail???

  • WaitFor() Does not wait for Process

    Experts,
    I have a Process p for a Microsoft Outlook Process OUTLOOK.EXE
    Now if there is an Email file (xyz.msg) opened as this process along with my MS Outlook running then,
    p.waitFor();
    // Where p = runner.exec(shell_command_to_open_msg_file);
    does not wait and move further.
    But if the MS Outlook is not running, then it waits till I manually close the Email msg file.
    How can I handle/overcome the former situation?
    Thanks in advance

    moondra_JavaDev wrote:
    How can I handle/overcome the former situation?
    You can't in java.
    What happens is that when outlook is already running then the new attempt to run does the following
    1. A application starts
    2. It determines that outlook is already running.
    3. It focuses that instance
    4. It exits.
    The last step is what you see. You do not have access to the one that is running because it isn't the same application.
    I would suggest examining the business requirements that are driving this. If you allow the user to already have outlook open then it seems rather odd that you are insisting that they exit it anyways. Instead you can pop a dialog and require that they tell you when they are done. Or don't use outlook and use java mail instead.

  • Wait for frame before showing another?

    If I have a JFrame that I pop up (to get user input), how do I prevent the "next" JFrame to pop up? By that I mean, I need to get some user input from the user before my code continues. I don't really want to use a JDialog unless I have to.
    The one idea I had didn' t work, which I really don't understand why?
    I had a class that extended Thread and in it I just had a frame that popped up with the user input I wanted. And then from the parent class (that created and started the class) I did a join() which I thought would work. But it didn't...

    This actually is the first thing that is shown as part of the intialization of the GUI. Actually just getting the users name and a few other things... But my application just burns right past the dialog and displays the application right after the dialog without waiting...
    I see now that the JFrame won't work since it isn't modal, but now that I wrapped a JDialog around it, with the modal flag as true, I don't see why it is still not working?

  • How long  i need to wait for processing item

    I am buying an Iphone 5 and my  order says     PROCESSING Items.   I am going to south america and I am afraid with the delay

    The Cloud allows install on both Windows and Mac... what program and version do you have?

  • WHENEVER I START ON CERTAIN WEBSITES A SHOCKWAVE PLUG IN ERROR MESSAGE APPEARS AND I HAVE TO WAIT FOR WEBSITE TO CONTINUE TO LOAD

    I HAVE WINDOWS 8.1 ON A PC WITH AN UP TO DATE FIREFOX BROWSER AND I HAVE DOWNLOADED AND INSTALLED SHOCKWAVE PLAYER SEVERAL TIMES. HERE IS THE ERROR MESSAGE THAT SHOWS UPPLEASE HELP THIS IS REALLY CAUSING ME AGGRAVATION!!

    I TRIED GOING TO CONFIG. AND MADE MY DOM. SETTING TO -1 I HOPE THAT FIXES THE PROBLEM.  IT WAS SET AT 45

  • Update of jlabel does not happen when i wait for thread to finish (join())

    gurus please help.
    I have a main application which in actionevent calls a thread, that thread calls parent method to update ths status in jlabel, but when i use thread.join() to wait for process to complete, the jlabel does not get updated, please tell me how can i update the jlabel, i have to wait for thread to finish and during run i need to update the jlabel.
    thanks

    hi camickr and gurus:
    here is the code:
    notice after pressing the Process button, the label is being updated but its not working. I called the processnow() method directly and also by thread, but in thread I have to wait until it finishes using join() but still does not work, please help. Thanks
    package label;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    import java.text.*;
    import javax.swing.border.*;
    import javax.swing.*;
    import javax.swing.table.*;
    import javax.swing.event.*;
    public class thePanel extends JDialog {
      private DefaultTableModel tableModel = null;
      private JTable theTable = new JTable();
      private JScrollPane scrollPane = new JScrollPane();
    JPanel tPanel = new JPanel();
      private Border mainBorder;
      private BorderLayout borderLayout1 = new BorderLayout();
      private BorderLayout borderLayout2 = new BorderLayout();
      private BorderLayout borderLayout3 = new BorderLayout();
      private BorderLayout borderLayout4 = new BorderLayout();
      private JPanel statusPanel = new JPanel();
      private JPanel buttonPanel = new JPanel();
      private JPanel lowerPanel = new JPanel();
      private JLabel statusBar = new JLabel();
      private JButton processButton = new JButton("Process");
      public JButton closeButton = new JButton("Close");
      boolean image = true;
      theProcess processThread;
      Vector tableData = new Vector();
      ImageIcon Image = new ImageIcon("image.gif");
      ImageIcon oImage= new ImageIcon("oimage.gif");
      boolean errorOcurred=false;
      String statusMessage;
      public thePanel() {
        try {
         jbInit();
        } catch(Exception e) {
          e.printStackTrace();
      private void jbInit() throws Exception {
        tPanel.setPreferredSize(new Dimension(800,424));
        mainBorder = new TitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED)," ");
        statusPanel.setBorder(BorderFactory.createEtchedBorder());
        tPanel.setBorder(mainBorder);
        tPanel.setLayout(borderLayout1);
        scrollPane.getViewport().add(theTable, null);
        tPanel.add(scrollPane,  BorderLayout.CENTER);
        // status
        statusPanel.setLayout(borderLayout2);
        statusPanel.setBorder(BorderFactory.createEmptyBorder());
        statusBar.setAlignmentX((float) 0.5);
        statusBar.setBorder(BorderFactory.createLoweredBevelBorder());
        statusBar.setMaximumSize(new Dimension(600, 21));
        statusBar.setMinimumSize(new Dimension(600, 21));
        statusBar.setPreferredSize(new Dimension(600, 21));
        statusPanel.add(statusBar, BorderLayout.SOUTH);
        // buttons
        processButton.setPreferredSize(new Dimension(70,25));
        processButton.addActionListener(new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            process_actionPerformed(e);
        closeButton.setPreferredSize(new Dimension(70,25));
        buttonPanel.setLayout(borderLayout3);
        buttonPanel.setBorder(BorderFactory.createRaisedBevelBorder());
        buttonPanel.add(processButton,BorderLayout.WEST);
        buttonPanel.add(new JPanel());
        buttonPanel.add(closeButton,BorderLayout.EAST);
        // lower panel
        lowerPanel.setLayout(borderLayout4);
        lowerPanel.setBorder(BorderFactory.createEmptyBorder());
        lowerPanel.add(statusPanel, BorderLayout.WEST);
        lowerPanel.add(buttonPanel, BorderLayout.EAST);
        tPanel.add(lowerPanel, BorderLayout.SOUTH);
        theTable.setAutoCreateColumnsFromModel(true);
        theTable.setColumnSelectionAllowed(false);
        theTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
        theTable.getTableHeader().setReorderingAllowed(false);
    getContentPane().add(tPanel);pack();
        getinfo();
    show();
      private void prepairTable(){
        tableModel = new DefaultTableModel(){
                          public boolean isCellEditable(int row, int col)
                            { return false; }};
        tableModel.addColumn("text 1");
        tableModel.addColumn("text 2");
        tableModel.addColumn("text 3");
        tableModel.addColumn("text 4");
        tableModel.addColumn("text 5");
        theTable.setModel(tableModel);
      } // end method (prepairTable)
      public void refreshTable() {
        prepairTable();
      public void getinfo() {
        try {
            refreshTable();
            tableModel.addRow(new Object[]{"3465465555","0123456789",new Date(1135022905196L),"0100000","errror message","sssssss"});
            tableModel.addRow(new Object[]{"8949344562","0324354549",new Date(1134511763683L),"0166600","errror mes666e","ddddddd"});
    setStatusMessage("ready to process, select record and click Process button to process record");
          errorOcurred = false;
        } catch (Exception ex) {
          errorOcurred = true;
          ex.printStackTrace();
        } // End try
      private void process_actionPerformed(ActionEvent e) {
        try {
          if(theTable.getSelectedRows().length > 0) {
    //        processThread = null;
    //        processThread = new theProcess(this);
    //        processThread.start();
    processnow();
            System.out.println("........finished now.........");
          } else {
        } catch (Exception ex) {
          ex.printStackTrace();
      public void processnow() {
        try {
          int[] selectedRows = null;
          int totalSelected = 0;
          setStatusMessage("processing " + totalSelected + " selected records...");Thread.sleep(1500);
          selectedRows = theTable.getSelectedRows();
          totalSelected = selectedRows.length;
          for(int i = 0; i < totalSelected ; i++){
            setStatusMessage("processing " + (i+1) + " of " + totalSelected + " selected records...");
            System.out.println(".......................row: "+selectedRows);
    Thread.sleep(2500);
    System.out.println("........fins...........");
    errorOcurred = false;
    } catch (Exception ex) {
    errorOcurred = true;
    ex.printStackTrace();
    } // End try
    public void setStatusMessage(String message) {
    statusMessage=message;
    SwingUtilities.invokeLater(new Runnable() {
    public void run() {
    if(image)
    statusBar.setIcon(Image);
    else
    statusBar.setIcon(oImage);
    statusBar.setText(statusMessage);
    statusBar.update(statusBar.getGraphics());
    public static void main(String[] args){
    new thePanel();
    } // class
    package label;
    import java.lang.Runnable;
    public class theProcess implements Runnable {
    private thePanel parent;
    public theProcess(thePanel xparent){
    parent = xparent;
    } // end constructor
    public void start() {
    try {
    Thread thisThread = new Thread(this);
    thisThread.start();
    thisThread.join();
    } catch(Exception ex) {
    ex.printStackTrace();
    } // end method (start)
    public void run(){
    try {
    parent.processnow();
    } catch (Exception ex){
    ex.printStackTrace();
    } // end try
    } // end method (run)
    } // end class

  • I'm using migration assistant to transfer files from my wife old net book to new mac air and the pc dropped out during transfer.  Pc now says waiting for mac to connect and has is stuck at transferring information.  How do I get the process to continue?

    I'm using migration assistant to transfer files from my wife old net book to new mac air and the pc dropped out during transfer. I started up migration assistant on the Pc again and now says waiting for mac to connect! New MacBook Air  is stuck at transferring information.  How do I get the process to reconnect and continue?

    Whew, good luck!
    What version of OSX is on the older one?

  • Call unix script within Servlet - need to wait for completetion

    Hi,
    I have a servlet which grabs some information from my web form and then calls a unix script.
    This already works fine and does what i need it to do. I now need to add some functionality where i can get the servlet to wait for the unix script to complete before carrying on and then redirecting back to the user.
    the code i have for the current servlet is:
             * EXECUTE THE UNIX COMMAND.
            Runtime   oRuntime  =     Runtime.getRuntime();
            Process   oProcess   =     null;
            String[]      cmd          =     {"/bin/sh", "-c", sPath}; // UNIX
             * ERROR CODES 3 = File not found
            try
              oProcess = oRuntime.exec(cmd);
            catch(Throwable t)
              t.printStackTrace();
            }I am assuming i need some sort of wait method to handle this. Any help would be greatly appreciated.
    Thanks
    Graham

    ok.. you code is fine.. you can run any shell script or program using the exec() method. if you need to wait till the process finishes then you need to call the method waitFor() in class Process.. the method blocks the parent thread (servlet) till the sub process (your exec'd script or program) terminates.
    hope that solves your problem.. :-)
    Pls tell me one more thing.. are you using netBeans or Eclipse for executing the programs or you use standalone tomcat to deploy the application. I have problem in execing programs when i deploy in tomcat 5.5 and the same application works fine in netBeans 5.0. if you know pls help me too..
    Thanks,
    -- abdel Olakara.

  • Can't open iphoto in airbook. Asking to upgrade then says must rebuild library then warning about missing files. When click rebuild all I get is continued- waiting for iphoto library- and, never rebuilds

    can't open iphoto in airbook. Asking to upgrade then says must rebuild library then warning about missing files. When click rebuild all I get is continued- waiting for iphoto library- and, never rebuilds

    -1.The photo library needs to be upgraded to work with this version of iPhoto.
    Your photo library will not be readable by previous versions of iPhoto after the upgrade. The upgrade process for very large libraries may take an hour or more to complete.
    2. iPhoto is unable to open this library.
    The library has issues that require rebuilding to correct
    3. Warning
    Would you like to rebuild the library "iPhoto Library"? 
    The library "iPhoto Library" is missing required database files and must be rebuilt before it can be opened.
    4. Waiting for iPhoto library
    iPhoto will open as soon as the iPhoto library is available
    Time Machine might be backing it up

Maybe you are looking for