0
나는 문제 NSApplescript를 사용하여 공간을 포함하는 경로 탈출에 봉착 : 할 경로에 응용 프로그램이 잘 때만NSApplescript 탈출 경로는 "쉘 스크립트를 수행 .."
이// mybashscript is in the bundle app (NSlog grant that is ok!)
NSDictionary*errorDict = nil;
NSAppleScript*mycommand;
NSString *mycommand = [mybashscript stringByReplacingOccurrencesOfString:@" " withString:@"\\ "];
// NSString *mycommand = [[mybashscript stringByReplacingOccurrencesOfString:@" " withString:@"\\ "] stringByReplacingOccurrencesOfString:@"/" withString:@":"]; // another test made
mycommand = [[NSAppleScript alloc] initWithSource:[NSString stringWithFormat:@"do shell script \"%@\" with administrator privileges", escapedPath]];
NSAppleEventDescriptor *eventDescriptor = [sudoPandoraMaker executeAndReturnError: &errorDict];
if (([eventDescriptor descriptorType]) && (errorDict==nil)) {
// if error is nil....is ok.. not this case :-(
} else {
NSLog(@"escapedPath è:%@", escapedPath);
// what's was wrong???
}
위의 코드가 작동을 공백을 포함하지 않지만 폴더 나 이름에 공백이있는 하드 드라이브로 이동하면 NSAppleScript가 실패합니다. 어떠한 제안? 감사합니다
응답 해 주셔서 감사합니다.하지만 "이벤트 오류 처리기"가 설정되어 있으므로 설정 한 문제는 공백이있는 경로를 (NSString을 사용하여) 해결하기가 어렵습니다. 해결 방법으로 해결 : 응용 프로그램이/Application 폴더에 있어야합니다. – Mike97