NSTask Class on OS X API , lets you run another program as a subprocess and monitor that program’s execution
Questions tagged [nstask]
452 questions
6
votes
1 answer
NSTask, command line tools and root
I'm working on an app that needs to use dd (I do this with a shell script in the app bundle, that collects parameters from the app itself, makes some checks and then launches dd).
To make this operation I need to call dd with root, and I already…
![](../../users/profiles/710767.webp)
opoloko
- 247
- 5
- 13
6
votes
1 answer
NSTask : Couldn't posix_spawn: error 13 when launching app
I have a sub-app in my main Swift app. I made it so it's copied automatically in the Resources folder of the main app when building it. That way, I want to be able to launch an instance of the sub-app from the main app.
The thing is, I'm having an…
![](../../users/profiles/1740412.webp)
Link14
- 788
- 1
- 12
- 29
6
votes
2 answers
cURL through NSTask not terminating if a pipe is present
I am trying to read the contents of a URL synchronously for a simple command-line batch script in Swift. I am using cURL for simplicity's sake - I know I could use NSURLSession if I had to. I am also building this with swift build using the…
![](../../users/profiles/284120.webp)
tobygriffin
- 5,079
- 3
- 35
- 57
6
votes
3 answers
How to give permission using NSTask - objective-c
I need to basically do a "sudo" but, I need to give that kind of permission to my NSTask code. Is this possible?
Thanks,
Elijah
![](../../users/profiles/1420271.webp)
objectiveccoder001
- 2,929
- 10
- 43
- 71
6
votes
0 answers
NSTask from sandboxed helper app fails with "Could not set sandbox profile data"
I’m working on a Mac OS app composed of a main app and a helper :
Backup.app/
└── Contents
├── Library
│ └── LoginItems
│ └── BackupHelper.app
├── MacOS
│ └── Backup
Backup.app: ask the user to select a path and save…
![](../../users/profiles/666789.webp)
Simon Watiau
- 627
- 5
- 16
6
votes
3 answers
NSTask or equivalent for iPhone
I've an open source project (gdal) that I want to compile and run as part of an iOS app. I had been expecting to use NSTask but I see now that it was removed in iOS 3.0. I've also seen elsewhere that running external applications, though this would…
![](../../users/profiles/186212.webp)
Craig
- 7,729
- 8
- 37
- 69
6
votes
1 answer
Communication between process using NSPipe,NSTask
I need to realize a communication between two threads using NSPipe channels, the problem is that I don't need to call terminal command by specifying this methods.
[task setCurrentDirectoryPath:@"....."];
[task setArguments:];
I just need to write…
![](../../users/profiles/1803863.webp)
Andrew
- 755
- 1
- 7
- 15
6
votes
2 answers
NSTask/NSPipe read from Unix command
I am writing a Cocoa application which needs to execute a UNIX program and read its output, line by line, as they are produced. I set up a NSTask and NSPipe as such:
task = [[NSTask alloc] init];
pipe = [NSPipe pipe];
[task…
![](../../users/profiles/514672.webp)
Actorclavilis
- 953
- 7
- 17
6
votes
1 answer
Controlling an interactive command-line utility from a Cocoa app - trouble with ptys
What I'm trying to do
My Cocoa app needs to run a bunch of command-line programs. Most of these are non-interactive, so I launch them with some command-line arguments, they do their thing, output something and quit. One of the programs is…
![](../../users/profiles/48660.webp)
pmdj
- 18,436
- 2
- 45
- 97
5
votes
1 answer
How can you start a LaunchAgent for the first time without rebooting, when your code runs as a LaunchDaemon?
I have a LaunchDaemon. When it runs, it checks if SIMBL is installed. If SIMBL is not installed, it uses NSTask to run /usr/sbin/installer on the SIMBL.pkg.
SIMBL's postflight script then tries to run a launchctl load command to start SIMBL's…
![](../../users/profiles/706428.webp)
jbrjake
- 124
- 1
- 8
5
votes
1 answer
Write to NSTasks standard input after launch
I am currently trying to wrap my head around the hole NSTask, NSPipe, NSFileHandle business. So I thought I write a little tool, which can compile and run C code. I also wanted to be able to redirect my stdout and stdin to a text view.
Here is what…
![](../../users/profiles/772398.webp)
Janek
- 111
- 1
- 5
5
votes
2 answers
How to read all remaining output of readInBackgroundAndNotify after NSTask has ended?
I'm invoking various command line tools via NSTask. The tools may run for several seconds, and output text constantly to stdout. Eventually, the tool will terminate on its own. My app reads its output asynchronously with…
![](../../users/profiles/43615.webp)
Thomas Tempelmann
- 9,137
- 6
- 60
- 120
5
votes
0 answers
Launch application with arguments with NSWorkspace not working
I would like to open FileZilla (ftp application) with an argument.
It is working with NSTask (aka. Process):
let process:Process = Process()
process.launchPath = appURL.path
process.arguments = ["ftp://1.2.3.4"]
process.launch()
It is not working…
![](../../users/profiles/345258.webp)
Daniel
- 2,227
- 2
- 27
- 51
5
votes
1 answer
Calling Gnuplot in Swift
I'm trying to call gunplot from swift to produce some plots in .png. However, the program below does not work --- the resulting 1.png file is empty. If I leave the "set term aqua" though, it does call the aqua window with the plot in it. However…
![](../../users/profiles/784533.webp)
Yrogirg
- 2,457
- 3
- 18
- 31
5
votes
0 answers
Sandboxed child process launced with NSTask fails silently
I'm building an OS X app that contains a command-line executable. The app calls the executable, passing along a filename that was chosen by the user, and grabs the output with a pipe. The code for doing this looks something like this:
let bundle =…
![](../../users/profiles/59364.webp)
Jack Nutting
- 606
- 3
- 9