Question

- (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

Was it helpful?

Solution

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  \"%@\""
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top