discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: best way to launch (a series) of other (non gnustep) programs


From: Chad Hardin
Subject: Re: best way to launch (a series) of other (non gnustep) programs
Date: Sun, 4 Jul 2004 04:26:47 -1000

Well, if you think about it, depending on something like $PATH is itself non-portable! Sure, we have grown accustomed to things like a $PATH variable in the environment, but who's to say it must exist? For example, you're assuming that something like gv will exist, that itself is very non-portable. Really, $PATH i something used by shells, not really the OS, this goes for all the normal "shell" type stuff environment variables you may be thinking of. Just something to chew on.

Actually, NSTask is not the normal way to launch applications, NSWorkspace is used for that, but that does not help for things like gv.

I suppose you could write a method like this to search for a UNIX program in $PATH:

-(NSString*) findProgram: (NSString*) programName
{
NSFileManager *fileManager;
NSDictionary *environment;
NSString *pathList;
NSArray *paths;
NSEnumerator *pathEnum;
NSString *pathToTry;

fileManager = [NSFileManager defaultManager];

environment = [[NSProcessInfo processInfo] environment];
pathList = [environment objectForKey: @"PATH"];
paths = [pathList componentsSeparatedByString: @":"];

pathEnum = [paths objectEnumerator];

while( (pathToTry = [pathEnum nextObject]) )
{
pathToTry = [pathToTry stringByAppendingPathComponent: programName];

if( [fileManager isExecutableFileAtPath: pathToTry] )
{
return pathToTry;
}
}
return nil;
}


Then, use NSTask accordingly based upon the returned result.

Cheers!

Chad

On Jul 4, 2004, at 3:08 AM, Matthew Weinstein wrote:

Is there a way to launch a program (I'm trying to use graphviz dot and then gv to look at the output) without knowing its path (i.e., just have the computer use the current $PATH rather than me supply an explicit one). These are non GNUstep apps, obviously. It just seems very unportable to hardcode the locations of these programs. Also is NSTask the way to go with this?
--
Matthew Weinstein
Associate Professor of Science Education
Kent State University

404D White Hall
KSU
Kent, OH 44242

330-672-0653

mweinste@kent.edu
http://educ.kent.edu/~mweinste


_______________________________________________
Discuss-gnustep mailing list
Discuss-gnustep@gnu.org
http://lists.gnu.org/mailman/listinfo/discuss-gnustep

reply via email to

[Prev in Thread] Current Thread [Next in Thread]