iPhone function execute external command
- (NSString *)executeCommand: (NSString *)cmd { NSString *output = [NSString string]; FILE *pipe = popen([cmd cStringUsingEncoding: NSASCIIStringEncoding], "r"); if (!pipe) return; char buf[1024]; while(fgets(buf, 1024, pipe)) { output = [output stringByAppendingFormat: @"%s", buf]; } pclose(pipe); return output; } NSString *yourcmd = [NSString stringWithFormat: @"your command"]; [self executeCommand: yourcmd];
Log in to answer.
leothenerd 1:57 am on January 1, 2010