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
2
votes
1 answer
How to open pdf/jpg in Preview by using NSTask on Lion?
I have following code working well on Snow Leopard. It opens a file stored in temporary directory with preferred application.
CFURLRef prefAppUrl = nil;
LSGetApplicationForURL((CFURLRef) tempUrl, kLSRolesAll, NULL, &prefAppUrl);
…

palob
- 372
- 1
- 3
- 11
2
votes
3 answers
Obj-C design pattern : parallel task launcher
I currently have a shell script that process many images one after the other, with the help of GraphicsMagick. It works fine, all calculations are correct, everything works. (that's not a "simple" script, it involves reading dimensions from a JSON…

Cyrille
- 25,014
- 12
- 67
- 90
2
votes
3 answers
Strange GDB behaviour once application is deployed to a jailbroken iPhone
Im trying to make an application which sends commands to GDB via NSTask and directs the output to the UITextView. It works well on the Mac (iOS Simulator). However, when deployed to the actual device (iPhone), it does not display any registers after…

Jared Aaron Loo
- 668
- 1
- 10
- 18
2
votes
2 answers
GDB throws cryptic error when invoked from NSTask
Im trying to use NSTask to invoke GDB, the variable "resultStringID" is actually the corresponding process ID and "abc" is just an NSString. My code for invoking GDB is as follows
NSMutableString *resultStringID = [NSMutableString…

Jared Aaron Loo
- 668
- 1
- 10
- 18
2
votes
2 answers
NSTask: does launch path of process exist
This code is used to get stdout of the process
NSTask * task;
NSPipe * pipe;
NSFileHandle * fileHandle;
task = [ [ NSTask alloc ] init ];
pipe = [ NSPipe pipe ];
fileHandle = [ pipe…

yolo
- 2,757
- 6
- 36
- 65
2
votes
1 answer
NSTask character output to NSTextField unbuffered as continuous stream
What I want to accomplish is to start a command line (CL) task (wrapped NSTask) and pipe (NSPipe) the character output through an NSTextField label in my UI, in real-time as a stream of characters. The purpose of the textfield is not to capture the…

pjv
- 566
- 3
- 16
2
votes
2 answers
NSTask: How to get context upon conclusion since no userInfo dictionary is supplied?
I'm trying to zip files using the command-line utility through NSTask.
pseudocode:
controller:
init:
register_self_as_observer_of_nstask_notifications
startZip(file):
file = somefileobject
task = "zip" with file path as argument
…

Alexandre
- 5,035
- 7
- 29
- 36
2
votes
1 answer
Convert NSTask "/bin/sh -c" command into proper pipeline code
Can someone help me convert the following code into code that instead has two NSTasks for "cat" and "grep", showing how the two can be connected together with pipes? I suppose I would prefer the latter approach, since then I no longer have to worry…

Enchilada
- 3,859
- 1
- 36
- 69
2
votes
1 answer
NSTask + calling NSLog in the task results in double printing messages to the console
I have a app that calls an NSTask, (I have written the NSTask and App code) and the NSTask calls NSLog at places where I want a line written out to the console.
Problem is that I see the console message from the NSTask, then I see the same message…

Tom Andersen
- 7,132
- 3
- 38
- 55
2
votes
0 answers
How to access "Standard Output" when running macOS executable?
Problem:
I'm trying to hook up the standard input/standard output from a unix executable file to the user interface in a MacOS application. But, I can't seem to access the values - nothing shows up.
Background:
I've implemented every solution that…

david-littlefield
- 584
- 5
- 13
2
votes
1 answer
Correctly execute shell commands in Swift 5
I'm new to swift and tried to follow several different tutorials on the internet to make my App run terminal stuff.
I have a checkbox that should enable (through the terminal command) the charging chime (and of course turn it off when…

Shade Reogen
- 136
- 2
- 13
2
votes
3 answers
NSTask Question
I'm trying to get my NSTask to unzip a file for me. This works fine if the path has no spaces, but when it does, it can't find any of the files. I can't hardcode the " signs because I'm storing the zip file in a temporary folder, which is assigned…

Pripyat
- 2,937
- 2
- 35
- 69
2
votes
3 answers
NSTask waitUntilExit hanging app on jailbroken iOS
So I've got NSTask to run a script which generates a list of something, into a txt, which I read from. But if I use my current code (below), the alert pops up before the NSTask is finished, thus resulting in a blank alert. I've tried waitUntilExit…

Mitochondria
- 43
- 1
- 5
2
votes
1 answer
Running a command as root in swift application
I was trying to implement a simple app in Xcode that would let me turn on and off a wifi interface. However, the ifconfig command requires root privileges to run "up" and "down". I've tried to run NSAppleScript but it returns
MessageTracer:…

Diego Bernal
- 61
- 1
- 6
2
votes
2 answers
Wrapping exclude option in an rsync NSTask method
I am trying to wrap rsync in NSTask and use the exclude option to not sync hidden files (dot files). I know this works at the command line:
rsync -az --exclude='.*' source destination
My NSTask is defined as follows:
NSTask *rsyncTask;
rsyncTask =…

Wilersh
- 85
- 1
- 5