29,027
社区成员
发帖
与我相关
我的任务
分享
int iRet = 0;
NSString * pPath = @"/Users/linhsmac/Proj/WdSpeedProj/build/Debug/openvpn";
NSArray * args =@[@"--log",
@"/Users/linhsmac/Proj/WdSpeedProj/build/Debug/opnvpn.log",
@"--config",
@"/Users/linhsmac/Proj/WdSpeedProj/build/Debug/client.ovpn",
@"--setenv",
@"IV_GUI_VER \"OpenVPN GUI 11\"",
@"--management",
@"127.0.0.1",
@"25340"
] ;
NSTask *task;
task = [[NSTask alloc] init];
[task setLaunchPath: pPath];
NSArray *argHelp;
argHelp = [NSArray arrayWithObjects: @"--help", nil];
//[task setArguments: argHelp];
[task setArguments: args];
NSPipe *pipe;
pipe = [NSPipe pipe];
NSPipe * inputPipe = [NSPipe pipe];
[task setStandardOutput: pipe];
[task setStandardInput:inputPipe];
NSFileHandle *file;
file = [pipe fileHandleForReading];
NSFileHandle * InFile = [inputPipe fileHandleForWriting];
NSString * pDir = @"/Users/linhsmac/Proj/WdSpeedProj/build/Debug";
[task setCurrentDirectoryPath:pDir];
[task launch];
const char *str = "\n";
NSData *data2 = [NSData dataWithBytes: str length:strlen(str)];
//[InFile writeData:data2];
NSData *data;
data = [file readDataToEndOfFile];
NSString *string;
string = [[NSString alloc] initWithData: data
encoding: NSUTF8StringEncoding];
NSLog (@"got\n%@", string);
018-09-14 20:19:34.179800+0800 WdSpeedProj[7241:139122] [General] launch path not accessible
2018-09-14 20:19:34.181702+0800 WdSpeedProj[7241:139122] [General] (
0 CoreFoundation 0x00007fff3738132b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x00007fff5e9ebc76 objc_exception_throw + 48
2 CoreFoundation 0x00007fff37412dcd +[NSException raise:format:] + 205
3 Foundation 0x00007fff395d5992 -[NSConcreteTask launchWithDictionary:error:] + 1304
4 WdSpeedProj 0x00000001000023e4 RunNSTask + 612
5 WdSpeedProj 0x0000000100002a26 RunOpenvpn + 710
6 WdSpeedProj 0x0000000100000f0e -[ViewController slConnectBtnClked:] + 46
7 AppKit 0x00007fff3502ea43 -[NSApplication(NSResponder) sendAction:to:from:] + 312
8 AppKit 0x00007fff34ad453f -[NSControl sendAction:to:] + 86
9 AppKit 0x00007fff34ad4467 __26-[NSCell _sendActionFrom:]_block_invoke + 136
10 AppKit 0x00007fff34ad436d -[NSCell _sendActionFrom:] + 183
11 AppKit 0x00007fff34b15688 -[NSButtonCell _sendActionFrom:] + 97
12 AppKit 0x00007fff34ad2bd6 -[NSCell trackMouse:inRect:ofView:untilMouseUp:] + 2438
13 AppKit 0x00007fff34b153cf -[NSButtonCell trackMouse:inRect:ofView:untilMouseUp:] + 777
14 AppKit 0x00007fff34ad1670 -[NSControl mouseDown:] + 965
15 AppKit 0x00007fff351cdd6d -[NSWindow(NSEventRouting) _handleMouseDownEvent:isDelayedEvent:] + 5891
16 AppKit 0x00007fff351ca9c4 -[NSWindow(NSEventRouting) _reallySendEvent:isDelayedEvent:] + 2359
17 AppKit 0x00007fff351c9c70 -[NSWindow(NSEventRouting) sendEvent:] + 497
18 AppKit 0x00007fff3502b236 -[NSApplication(NSEvent) sendEvent:] + 2462
19 AppKit 0x00007fff3488b8b5 -[NSApplication run] + 812
20 AppKit 0x00007fff3485aa72 NSApplicationMain + 804
21 WdSpeedProj 0x00000001000010e2 main + 34
22 libdyld.dylib 0x00007fff5f605015 start + 1
)