このコードでNSTaskにどのように引数(この場合はホスト)を渡すのですか?ホストNSString
を受け入れません。 pingを使用してホスト値を渡すと、たとえば、コマンドラインツールを実行しているときのNSTaskと引数
[NSArray arrayWithObjects:@"-c",@"ping -c 5 www.google.com",nil]
のようになります。しかし、それはホストの議論を別々に取ることはありません。事前に助けてくれてありがとう。
task = [[NSTask alloc] init];
[pipe release];
pipe = [[NSPipe alloc] init];
[task setStandardInput: [NSPipe pipe]];
[task setLaunchPath:@"/bin/bash"];
NSArray *args = [NSArray arrayWithObjects:@"-c",@"ping -c 5",host,nil];
[task setArguments:args];
[task setStandardOutput:pipe];
NSFileHandle *fh = [pipe fileHandleForReading];
ありがとうございます。それは魅力のように働いた。 – ZionKing