Professional Web Applications Themes

Restarting my app programmatically? - Mac Programming

I'm sure this is a common thing to do. I want to restart mine after a user enters a valid registration code. I'm thinking: 1) cron job Can cron set jobs just a few seconds ahead in time? 2) helper app A command line tool that you pass an argument which is an application to open. It waits 2 seconds or so, (or maybe monitors to see when the process actually quits) and then launches it and returns. It occured to me after thinking of #2 that there probably exists such an app already, esp. since all developers could share ...

  1. #1

    Default Restarting my app programmatically?

    I'm sure this is a common thing to do. I want to restart mine after a
    user enters a valid registration code.

    I'm thinking:

    1) cron job
    Can cron set jobs just a few seconds ahead in time?

    2) helper app
    A command line tool that you pass an argument which is an application to
    open. It waits 2 seconds or so, (or maybe monitors to see when the
    process actually quits) and then launches it and returns.

    It occured to me after thinking of #2 that there probably exists such an
    app already, esp. since all developers could share it if it was standard
    with the OS.

    Any tips are much appreciated.

    Mark

    --
    |\/| /| |2 |<
    mehaase(at)sas(dot)upenn(dot)edu
    Mark Guest

  2. #2

    Default Re: Restarting my app programmatically?

    In article <upenn.edu>,
    Mark Haase <net> wrote:
     

    Yikes! I suppose you can schedule it anytime you want, but you'll also
    need to un-schedule it. This would be awkward and error-prone.
     

    No need, just use a script that looks something like this (warning, not
    tested):

    -------------------------
    #!/bin/sh

    # Set the number to however many seconds you like
    sleep 5

    /usr/bin/open /Path/to/your/app
    -------------------------

    But surely it should be possible for your app to respond to the new code
    without restarting itself...

    --
    Tom "Tom" Harrington
    Macaroni, Automated System Maintenance for Mac OS X.
    Version 2.0: Delocalize, Repair Permissions, lots more.
    See http://www.atomicbird.com/
    Tom Guest

  3. #3

    Default Re: Restarting my app programmatically?

    In article <upenn.edu>,
    Mark Haase <net> wrote:
     

    Why do you need to restart at all? If you need to check the registration
    status during runtime, a simple flag should do. Do you need to reload
    bundles or enable features that require a bundle to reload? I'm sorry I
    don't have an answer for you, but I'm thinking that maybe there's a
    better way.
    Lorenzo Guest

  4. #4

    Default Re: Restarting my app programmatically?

    In article <tph-508603.14295404022004localhost>,
    Tom Harrington <no.spam.dammit.net> wrote:
     

    Yeah, it ought to be. I'm doing that now in my application, but
    occasionally it s up. There are a few things that need to change
    when the user registers and I'm having a hard time keeping track of
    them. I suppose I could be more diligent, but I thought that restarting
    would be dead easy, and not too slow since my app is small.

    --
    |\/| /| |2 |<
    mehaase(at)sas(dot)upenn(dot)edu
    Mark Guest

  5. #5

    Default Re: Restarting my app programmatically?

    Mark Haase wrote: 

    There is such an app, and ye shall call it AppleScript.

    - (void)relaunchApp {
    NSMutableString* command=
    [NSMutableString stringWithString:"osascript "];
    [command appendString:"-e 'tell application \"FooBar\" to quit' "];
    [command appendString:"-e 'delay 2' "]; //this should be a more
    sophisticated check
    [command appendString:"-e 'tell application \"Finder\" to launch
    application \"FooBar\"' "];
    [command appendString:" &"]; //allows system() to return so we can
    process quit AppleEvents
    system([command cString]);
    }

    This worked when I tried it.

    -Peter

    Peter Guest

Similar Threads

  1. CF restarting itself
    By mbiebrich in forum Macromedia ColdFusion
    Replies: 2
    Last Post: August 26th, 03:47 PM
  2. Restarting
    By Jeff in forum Windows XP/2000/ME
    Replies: 3
    Last Post: August 10th, 03:09 AM
  3. restarting IIS from within ASP.NET
    By Simon Weaver in forum ASP.NET General
    Replies: 0
    Last Post: July 22nd, 07:54 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139