I want to use command line in Cocoa for record of the password in a bunch of keys. But I can't insert a variable at line. How to make it?
How $pass to provide me self.PassKey?
self.PassKey = [_PassTextField stringValue];
NSTask *taskPass = [[NSTask alloc] init];
[taskPass setLaunchPath:@"/bin/bash"];
[taskPass setArguments:[NSArray arrayWithObjects: @"-c", @"/usr/bin/security delete-generic-password -a ${USER} -s post | security add-generic-password -a ${USER} -s post -w $pass", nil]];
[taskPass launch];
Thanks for any help!
Thanks to all for the help and such prompt reply!
So works:
self.PassKey = [_PassTextField stringValue];
NSLog(@"text changed: %@", self.PassKey); ///I printed in a window the password 12345
NSString * command = [NSString stringWithFormat:@"/usr/bin/security delete-generic-password -a ${USER} -s post | security add-generic-password -a ${USER} -s post -w %@", self.PassKey]; ///I receive a line /usr/bin/security delete-generic-password -a ${USER} -s postftp | security add-generic-password -a ${USER} -s postftp -w 12345
NSLog(@"command line: %@", command);
NSTask *taskPass = [[NSTask alloc] init];
[taskPass setLaunchPath:@"/bin/bash"];
[taskPass setArguments:[NSArray arrayWithObjects: @"-c", command, nil]];
[taskPass launch];
Record of the password in a bunch of keys results.