2011-11-17 100 views
1

我是Cocoa的初學者。我想從我的類執行一個Perl腳本,我沒有得到任何結果,以下是代碼:從Xcode 4.2執行Perl腳本

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMast, YES); 
NSString *documentDir = [paths objectAtIndex:0]; 
NSString *path = [documentDir stringByAppendingPathComponent:@"detect.pl"]; 

NSMutableArray *someArray = [[NSMutableArray alloc] initWithObjects:path, nil]; 

[[NSTask launchedTaskWithLaunchPath:[NSString stringWithFormat:@"/usr/bin/pl"] arguments:someArray] waitUntilExit]; 

我得到了下面的文字

pl {-input <file>} {-output <file>} 
    Reads ASCII PL from stdin (or file if -input specified) 
    and writes ASCII PL to stdout (or file if -output) 
    NOTE: binary serialization is no longer supported 

代碼停止的執行在那裏。我不確定我做錯了什麼,有人可以請我指出正確的方向。謝謝。

回答

3

您需要執行/usr/bin/perl而不是/usr/bin/pl

+0

謝謝jimtut,工作。 – Ruwenzori

+0

不幸的是,我面臨着另一個問題,我可能會錯過一些東西。一旦perl腳本完成執行,它會在NSLog中顯示結果,這很好。但是,Xcode不會在perl腳本執行後評估更多代碼。 – Ruwenzori

+0

我是一個Perl人,而不是Xcode人。所以我害怕超越。打開一個新問題 - 我相信你會得到一些幫助! – jimtut