Restarting an app -- AppleScript 'launch' in a detached shell
Restarting an app -- AppleScript 'launch' in a detached shell
- Subject: Restarting an app -- AppleScript 'launch' in a detached shell
- From: Steve Cronin <email@hidden>
- Date: Sun, 03 Aug 2008 16:00:25 -0500
Folks;
I am trying to simply restart my app. To my dismay, I cannot find a
way to do this in Cocoa.
Please enlighten me if I have failed to understand something!!
After perusing the archives, what makes the most sense to me is to
launch a detached shell that executes a simple AppleScript.
The script has a delay of 2 seconds and then simply does a 'launch'.
I've got the script working like a champ in a straight terminal session:
> /usr/bin/osascript '/Users/steve/Desktop/Restart.script'
So now:
NSString *cmdString = [NSString stringWithFormat:@"/usr/bin/osascript
'%@'",[[self scriptsFolderPath
stringByAppendingPathComponent:@"Restart.script"]];
NSTask *task = [[[NSTask alloc] init] autorelease];
[task setLaunchPath:@"/bin/sh"];
[task setArguments:[NSArray arrayWithObjects:@"-c", cmdString, @" &",
nil]]; //the '&' detaches the shell, yes?
[task setStandardError:[NSFileHandle
fileHandleForWritingAtPath:errorOutPath]];
[task waitUntilExit]; // <-- I've also tried [task
launch] but the same result.
[[NSApplication sharedApplication] terminate:self];
This unsurprisingly DOES quit the application but the script doesn't
appear to execute, nothing further happens...
Am I not using the argument list correctly?
I also do not see anything at all in the file @ errorOutPath nor do
I don't see any console messages.
How could I pick up any data on what IS happening?
I know I am missing something here but I AM puzzled...
Thanks for any help!
Steve
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden