views:

21

answers:

1
- (IBAction) charlieImputText:(id)sender {

NSAppleScript *keystrokeReturn = [[NSAppleScript alloc] initWithSource:@"tell application \"System Events\" to keystroke return"];
[keystrokeReturn executeAndReturnError:nil];

[progressBarText startAnimation:self];

charlieImputSelf = [sender stringValue];

NSAppleScript *sendCharlieImput = [[NSAppleScript alloc] initWithSource:[NSString stringWithFormat:@"tell application \"Terminal\" to do shell script  %@", charlieImputSelf]];
[sendCharlieImput executeAndReturnError:nil];

NSDictionary* errorDict;
NSAppleScript* script=[[NSAppleScript alloc] 
                       initWithContentsOfURL:[NSURL fileURLWithPath:@"/applications/jarvis/scripts/getTextCharlieResponce.scpt" ]
                       error:&errorDict];
NSAppleEventDescriptor* desc=[script executeAndReturnError:&errorDict];
NSString* result=[desc stringValue];
self.charlieOutput.stringValue = result;
charlieOutput.textColor = [NSColor greenColor];
[script release];

[progressBarText stopAnimation:self];

}

I'm such a newbie to this and I posted a problem with this code in another question and someone responded to me with this:

You need to quote the argument to do shell script.

What does this mean?? Can someone show an example??

I'm soooo sorry, I have no clue what this new age lingo means! :D

A: 

In your code you have:

@"tell application \"Terminal\" to do shell script  %@"

That %@ is the "argument" of the command "do shell script". So I guess what you need is:

@"tell application \"Terminal\" to do shell script  \"%@\""
JWWalker
Ok thanks!! It still doesn't work though.... :(Any ideas??
Elijah W.
"Doesn't work" is a tad vague. Where does it go wrong? If the first `executeAndReturnError` step fails, then you shouldn't be passing nil to it. You want to see the error info.
JWWalker
Ok, I got it! User error...sorry...love this place though...
Elijah W.