NSTask Class on OS X API , lets you run another program as a subprocess and monitor that program’s execution
Questions tagged [nstask]
459 questions
0
votes
0 answers
NSTask stdout consuming large amount of memory
I'm running a command via NSTask that generates a very large amount of output. I created a pipe connected to standard output and am using waitForDataInBackgroundAndNotify and consuming the data with availableData. However it appears that all of the…

stdout
- 1,761
- 1
- 18
- 33
0
votes
2 answers
Execute a terminal command from a Cocoa Desktop app
I am trying to execute a command for creating a Cordova Project in my Cocoa Desktop App but It doesn't work.
That's my code:
NSTask *task = [NSTask new];
[task setLaunchPath:@"/Documents/Cordova/bin/ ./create ~/Documents/Cordova/HelloWorld2…

cmltkt
- 193
- 3
- 16
0
votes
0 answers
NSUserScriptTask: cancelling tasks?
Is there any way to cancel a running NSUserScriptTask? The only way that comes to mind is to launch a separate process (a command line tool) via NSTask, whose only purpose is to run the NSUserScriptTask, and then terminate the command line tool via…

Alex
- 5,009
- 3
- 39
- 73
0
votes
1 answer
NSTask works in xcode run but not when i run it outside xcode
I have created this app that make use of the /usr/bin/say command in OS X.
This method takes the value from a textfield and uses "say" to save it.
But when i run this outside xcode. I don't get the saved file.
- (IBAction)save:(id)sender
{
…

nikora
- 817
- 1
- 14
- 29
0
votes
2 answers
Get output of shell command in ObjC
I've read solutions for doing this using NSTask: they all look very very long... So I managed to do the exact same thing using this code (which gets both standard output and standard error):
NSTask *task = [NSTask new];
[task…

user732274
- 1,069
- 1
- 12
- 28
0
votes
0 answers
reason: 'couldn't fork: errno 35' while importing video files ,converting and getting creation date
I am trying to import files from sdCard using sdcard reader on ipad. While importing the mts files from the card, i convert them to mov format and save it to the documents directory of the application. It completely converts the files if i dont call…

Farrukh Iqbal
- 1
- 1
0
votes
1 answer
Shell Command output in NSTextView
Thanks for the help. The results of this executed command is displayed in my Xcode Console. What's the best way to get the results of the command to be displayed in an NSTextView?
NSString *commandToRun = @"~/Library/webREF/ffmpeg -nostats -i…

Paul
- 189
- 10
0
votes
0 answers
NSTask Execute string
How can I execute set of shell script using NSTask
The Below string must be executed using NSTask.
NSString *aString = @"MY_USERNAME=\"SAM\"\
PROJDIR=\"/Path\"\
APPLICATION_NAME=\"AppName\"\
PROJECT_NAME=\"${APPLICATION_NAME}\" # .xcodeproj…

Ganesh Nayak
- 802
- 11
- 38
0
votes
2 answers
COCOA : Bring an application to front launched from NPAPI Plugin
I have a NPAPI plugin for MAC that downloads and runs an Application from server.
When i use NSTask to open up the application. The application does not come to front.
NSBundle *bundle = [NSBundle bundleWithPath:AppPath];
NSString *path = [bundle…

LazyCoder7
- 45
- 10
0
votes
1 answer
Trying to run cli with NSTask is failing
I am trying to run the following in a cocoa app:
cat PATHTOFILE | python -mjson.tool > OUTPUTFILE
NSTask *task = [[NSTask alloc] init];
[task setLaunchPath: @"/bin/cat"];
NSArray *arguments = [NSArray arrayWithObject: path];
[task…

mootymoots
- 4,545
- 9
- 46
- 74
0
votes
0 answers
task processIdentifier cocoa
Ok here is my code..
The return of tid is usually about 2-3 off of the actual pid. It is driving me crazy trying to figure out why it will not give me the exact pid.
So when I try to kill the process, it will not kill, I suppose i could write one to…

Richard Williamson
- 154
- 8
0
votes
1 answer
Handling error when using NSTask
As a learning project Im writing a simple gui for Apache stresstesting command line tool "ab". It requiers a full URL, including a filename such as index.html or simular, as one of its parameters. If a filename is not specified "ab" echos "Invalid…

Kalle
- 452
- 2
- 4
- 19
0
votes
1 answer
why waitForDataInBackgroundAndNotify doesn't work with the real time monitor with more than 1 argument?
I have found the following code from one of the API, and I'm trying to use it to do a real time monitoring of vm_stat 1:
BOOL terminated = NO;
-(void)realTimeMonitor
{
NSTask *task = [[NSTask alloc] init];
[task setLaunchPath:@"/bin/bash"];
[task…

Josh
- 692
- 2
- 9
- 38
0
votes
3 answers
Escaping backslashes in NSTask arguments?
I am trying to get the latest modification date in a directory tree.
This works fine in terminal:
find . ! -path "*.git*" -exec stat -f "%m" \{} \; | sort -n -r | head -1
But when I try this with NSTask I get
find: -exec: no terminating ";" or…

Tycho Pandelaar
- 7,367
- 8
- 44
- 70
0
votes
1 answer
Output text from NSTask to NSTextField OS X - XCode Objective -C
I was wondering how I would output text from NSTask and send it to a NSTextField on OSX.

HamishClaxton
- 11
- 4