Hello MacRumors;
I have been working on a few projects in Objective-C recently and have found it extremely difficult (if not impossible) to run a shell command/script from the code.
I have found this code for running a shell script from the resources folder:
The only thing is that I'd like to be able to use type the command right into the code; for example:
touch /Users/myusername/Desktop test.txt
Any help would be greatly appreciated, Thanks!
I have been working on a few projects in Objective-C recently and have found it extremely difficult (if not impossible) to run a shell command/script from the code.
I have found this code for running a shell script from the resources folder:
Code:
NSTask *task = [[NSTask alloc] init];
[task setLaunchPath:@"/bin/sh"];
[task setArguments:[NSArray arrayWithObjects:[[NSBundle mainBundle] pathForResource:@"sscript" ofType:@"sh"], nil]];
[task launch];
The only thing is that I'd like to be able to use type the command right into the code; for example:
touch /Users/myusername/Desktop test.txt
Any help would be greatly appreciated, Thanks!