That doesn't appear to work here. Perhaps if I give more detail about what exactly Im doing, a solution will be more clear. Inside a known directory, exists a file that has the string "logfile_" in it. Inside this file, there is one line that contains the word "Completed in it. I need to get this line from this text file. What I was doing previously was using NSTask to do a grep with the word to search for and the file path to logfile_01.txt as arguments. this worked fine until I realized that the file name changed after a time. Here is my present code that only works until the file name changes.
-(void)grepForProgBarStart
{
NSTask *initializeProgressBar=[[NSTask alloc] init];
NSPipe *pipe=[[NSPipe alloc] init];
NSFileHandle *handle;
NSString *FAHOneLog = @"/Users/xaos01/Library/Application\ Support/Origami/FAH1/work/logfile_01.txt:";
NSString *string;
[initializeProgressBar setLaunchPath:@"/usr/bin/grep"];
[initializeProgressBar setArguments:[NSArray arrayWithObjects:@"Completed", FAHOneLog, nil]];
[initializeProgressBar setStandardOutput

ipe];
handle=[pipe fileHandleForReading];
[initializeProgressBar launch];
string=[[NSString alloc] initWithData:[handle readDataToEndOfFile] encoding:NSASCIIStringEncoding];
string = [[string componentsSeparatedByString:@": "] objectAtIndex:1];
string = [[string componentsSeparatedByString:@","] objectAtIndex:0];
[progressBar setDoubleValue:[string intValue]];
[pipe release];
[initializeProgressBar release];
}
Would it help if I wasnt using grep to do this?
Other ways to determine the right file:
Its always the second file in the directory when the directory is sorted alphabeticaly.
Its always the only file that ends in ".txt"
could i some how make an array of strings that contain the name of each file in the known directory and then use objectAtIndex to give me the string at object 1? I believe the answer lies in making an array of the file names and doing something with it but Im not sure.