Hi guys,
Fist post for a french developer! I'm trying to create a simple synchronization using rsync and objective-c. So I used NSTask like that :
NSTask *task = [[NSTask alloc] init];
[task setLaunchPath:@"/usr/bin/rsync"];
NSArray* args = [NSArray arrayWithObjects:@"-av", @"/Users/BiB1/Documents/test/", @"[email protected]:~/test/", nil];
NSDictionary* env = [NSDictionary dictionaryWithObject:<#(id)object#> forKey:<#(id)key#>
[task setArguments:args];
NSPipe *outPipe = [[NSPipe alloc] init];
[task setStandardOutput:outPipe];
[outPipe release];
[task launch];
NSData *data = [[outPipe fileHandleForReading] readDataToEndOfFile];
[task waitUntilExit];
int status = [task terminationStatus];
[task release];
if(status != 0)
{
NSDictionary *eDict = [NSDictionary dictionaryWithObject:@"Sync impossible" forKey:NSOSStatusErrorDomain];
NSError *outError = [NSError errorWithDomain:NSOSStatusErrorDomain code:0 userInfo:eDict];
NSLog(@"EDICT : %@",eDict);
NSLog(@"ERROR : %@",outError);
}
NSString *aString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
[self.textField setStringValue:aString];
[aString release];
In the terminal the command work fine but I have a request for the password. And in NSTask I don't have this request.
So my question is, there is a method for catching crendential needed, or is it possible to set password as parameter or something else.
Thanks by advance.
BiB1