1
Je voudrais lancer la commande suivante de mon application à l'aide NSTask:commande Lancement à l'aide NSTask renvoie l'erreur
-u myusername launchctl sudo charge /Library/LaunchAgents/com.google.keystone.agent.plist
Voici un code que je fais: NSPipe * pipe = [NSPipe pipe];
NSTask *task = [[NSTask alloc] init];
[task setLaunchPath: @"/bin/sh"];
[task setCurrentDirectoryPath:@"/"];
[task setStandardError:pipe];
NSArray *arguments = nil;
arguments = @[@"sudo",
@"-u",
@"myusername",
@"launchctl",
@"load",
@"/Library/LaunchAgents/com.google.keystone.agent.plist"];
[task setArguments: arguments];
NSFileHandle * read = [pipe fileHandleForReading];
[task launch];
[task waitUntilExit];
NSData * dataRead = [read readDataToEndOfFile];
NSString * output = [[NSString alloc] initWithData:dataRead encoding:NSUTF8StringEncoding];
NSLog(@"output: %@", output);
Après le traitement que je reçois une erreur ci-dessous:
/bin/sh: sudo: Aucun fichier ou répertoire
que fait le "-c"? pourquoi ça marche? – iksnae