5 * Created by Jack Jansen on Wed Jul 31 2002.
6 * Copyright (c) 2002 __MyCompanyName__. All rights reserved.
10 #import <Cocoa/Cocoa.h>
11 #import <ApplicationServices/ApplicationServices.h>
15 doscript(const char *command)
17 char *bundleID = "com.apple.Terminal";
22 [[NSWorkspace sharedWorkspace] launchApplication:@"/Applications/Utilities/Terminal.app/"];
25 err = AEBuildAppleEvent(kAECoreSuite, kAEDoScript,
26 typeApplicationBundleID,
27 bundleID, strlen(bundleID),
28 kAutoGenerateReturnID,
31 "'----':utf8(@)", strlen(command),
34 NSLog(@"AEBuildAppleEvent failed: %d\n", err);
38 // Send event and check for any Apple Event Manager errors
39 err = AESendMessage(&evt, &res, kAEWaitReply, kAEDefaultTimeout);
42 NSLog(@"AESendMessage failed: %d\n", err);
45 // Check for any application errors
46 err = AEGetParamDesc(&res, keyErrorNumber, typeSInt32, &desc);
49 AEGetDescData(&desc, &err, sizeof(err));
50 NSLog(@"Terminal returned an error: %d", err);
52 } else if (err == errAEDescNotFound) {
55 NSLog(@"AEGetPArmDesc returned an error: %d", err);