1998-01-21 14:56:24 +00:00
|
|
|
#include <Foundation/NSAutoreleasePool.h>
|
1998-04-02 14:27:40 +00:00
|
|
|
#include <Foundation/NSProcessInfo.h>
|
1998-01-21 14:56:24 +00:00
|
|
|
#include <Foundation/NSTask.h>
|
|
|
|
|
|
|
|
int
|
|
|
|
main()
|
|
|
|
{
|
|
|
|
id pool;
|
1998-04-02 14:27:40 +00:00
|
|
|
NSDictionary *env;
|
1998-01-21 14:56:24 +00:00
|
|
|
NSTask *task;
|
2001-02-05 09:28:19 +00:00
|
|
|
NSData *d;
|
1998-01-21 14:56:24 +00:00
|
|
|
|
|
|
|
pool = [[NSAutoreleasePool alloc] init];
|
|
|
|
|
2000-09-22 04:20:52 +00:00
|
|
|
#ifdef __MINGW__
|
|
|
|
task = [NSTask launchedTaskWithLaunchPath: @"C:\\WINDOWS\\COMMAND\\MEM.EXE"
|
|
|
|
arguments: nil];
|
|
|
|
#else
|
1998-01-21 14:56:24 +00:00
|
|
|
task = [NSTask launchedTaskWithLaunchPath: @"/bin/ls"
|
|
|
|
arguments: nil];
|
2000-09-22 04:20:52 +00:00
|
|
|
#endif
|
1998-01-21 14:56:24 +00:00
|
|
|
[task waitUntilExit];
|
|
|
|
printf("Exit status - %d\n", [task terminationStatus]);
|
|
|
|
|
1998-04-02 14:27:40 +00:00
|
|
|
[pool release];
|
|
|
|
pool = [[NSAutoreleasePool alloc] init];
|
|
|
|
|
|
|
|
task = [NSTask new];
|
|
|
|
env = [[[[NSProcessInfo processInfo] environment] mutableCopy] autorelease];
|
|
|
|
[task setEnvironment: env];
|
|
|
|
[task setLaunchPath: @"/bin/sh"];
|
|
|
|
[task setArguments: [NSArray arrayWithObjects: @"-c", @"echo $PATH", nil]];
|
2001-02-05 09:28:19 +00:00
|
|
|
if ([task usePseudoTerminal] == NO)
|
|
|
|
printf("Argh - unable to use pseudo terminal\n");
|
1998-04-02 14:27:40 +00:00
|
|
|
[task launch];
|
2001-02-05 09:28:19 +00:00
|
|
|
d = [[task standardOutput] availableData];
|
|
|
|
NSLog(@"Got PATH of '%*s'", [d length], [d bytes]);
|
|
|
|
|
1998-04-02 14:27:40 +00:00
|
|
|
[task waitUntilExit];
|
|
|
|
[task release];
|
1998-01-21 14:56:24 +00:00
|
|
|
[pool release];
|
|
|
|
|
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
|