0
- (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];

}

我是一个新手,我在另一个问题中发布了这个代码的问题,有人用这个回复我:

您需要引用参数来执行 shell 脚本。

这是什么意思??有人可以举个例子吗?

对不起,我不知道这个新时代的术语是什么意思!:D

4

1 回答 1

0

在您的代码中,您有:

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

%@是命令“do shell script”的“参数”。所以我想你需要的是:

@"tell application \"Terminal\" to do shell script  \"%@\""
于 2010-07-03T02:19:32.797 回答