• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Unix program wrapper problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Unix program wrapper problem


  • Subject: Unix program wrapper problem
  • From: email@hidden
  • Date: Fri, 03 Feb 2006 22:04:44 +0000

Here is the problem.  I have a set of unix database searching programs in the
directory:
/Blast/bin

So when I use the command 'cd /Blast/bin'

and then

'/Blast/bin/blastall -p blastn -d ecoli.nt -i test.txt -o out.txt'

The blastall program compares the contents of the file test.txt against the
ecoli.nt database and outputs the results in out.txt (which it creates).  There
are absolutely no problems.  Note that test.txt and ecoli.nt are in /Blast/bin as well that's why I switch to that directory.

I want to write a wrapper so that I can run the command from a mac app.  I am using the code example I found in Cocoa programming.  When I try to run the program (code is below) I get the following error:

[NULL_Caption] FATAL ERROR: blast: Unable to open input file  test.txt

I try writing full path names for the database and the input file - didn't work.  Any ideas of what I am doing wrong.  My code is listed below.

Thanks

Sarven

------------------------

#import "blastController.h"

@implementation blastController

- (void)applicationDidFinishLaunching:(NSNotification *)notification
{
	//ignore for now
        //[self theButton:self];
}

- (IBAction)theButton:(id)sender
{
	NSString *resultText;
	//Set up an array for passing the arguments to the blastall command
	NSMutableArray *blastArgs=[NSMutableArray array];
	[blastArgs addObject:@"-p blastn"];
	[blastArgs addObject:@"-d ecoli.nt"];
	[blastArgs addObject:@"-i test.txt"];
	[blastArgs addObject:@"-o testout.txt"];
	//Call the subroutine to run the blastall command and get the text
output in resultText
	resultText=[self runCommand:@"/Blast/bin/blastall"
withArguments:blastArgs];
	{
        //display the text
		int length = [[textField string] length];
        [textField setSelectedRange:NSMakeRange(0, length)];
        [textField setEditable:YES];
        [textField insertText:resultText];
        [textField setEditable:NO];
    }
}

- (NSString *)runCommand:(NSString *)command withArguments:(NSArray *)args
{
	NSTask *task = [[NSTask alloc] init];
    NSPipe *newPipe = [NSPipe pipe];
    NSFileHandle *readHandle = [newPipe fileHandleForReading];
	NSData *inData;
	NSString *tempString;

	//Set the directory and do the setup for running the commans
	[task setCurrentDirectoryPath:@"/Blast/bin"];
    [task setLaunchPath:command];
    [task setArguments:args];
	[task setStandardOutput:newPipe];
	[task setStandardError:newPipe];
	//Run the command
    [task launch];
	//Get the Output
	inData = [readHandle readDataToEndOfFile];
	tempString = [[NSString alloc] initWithData:inData
encoding:NSASCIIStringEncoding];
	[task release];
	[tempString autorelease];
	return tempString;
}
@end
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Unix program wrapper problem
      • From: Markus Hitter <email@hidden>
    • Re: Unix program wrapper problem
      • From: Derrick Bass <email@hidden>
    • Re: Unix program wrapper problem
      • From: Andreas Färber <email@hidden>
  • Prev by Date: Re: arrays of doubles
  • Next by Date: Toolbar with unifier toolbar/title bug?
  • Previous by thread: NSBitmapImageRep RGBA byte order endianess
  • Next by thread: Re: Unix program wrapper problem
  • Index(es):
    • Date
    • Thread