I'd like to run some terminal command within my Mac program.
For example, I normally use mate abc.txt
or python abc.py
from my shell to open Text Mate or running python script.
How can I do the same thing with Cocoa/Objective-C?
I thought about this method, but I prefer just running in one line.
For example, when users enter "python abc.py", I just run the command as if it's in the Terminal.app. Python's equivalent command is os.system()
.
<-- inputItem TextField
NSString* item = [inputItem stringValue];
[NSRuncommandLikeShell item]; <-- ????
The environment variables should be retained so that I don't need to run '/usr/bin/python'.
EDIT
I can use ~/.MacOSX/environment.plist
file for setup path environment. Or, I also could use this utility for GUI.