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
1
vote
2 answers
What is going on when I run a terminal/shell command in Swift?
I've spent a fair amount of researching how to run a particular terminal/shell command from within Swift.
The issue is, I'm afraid to actually run any code unless I know what it does. (I've had very bad luck with executing terminal code in the…

Pro Q
- 4,391
- 4
- 43
- 92
1
vote
1 answer
Interactive access to command using NSTask
I am using an NSTask to run a cli app that in interactive. Im using it to pull data over a USB connection.
I am opening an NSTask with an outline and error pipe but when I issue a command, it works, but spins the beach ball in the loop pulling data…

JeremyLaurenson
- 979
- 2
- 11
- 23
1
vote
1 answer
Start python file in Swift
I want to start a pythonscript by pushing a Button in a swift macOS application. I come up with:
let process = Process()
process.launchPath = "/usr/bin/python3"
process.currentDirectoryPath = "\(NSHomeDirectory())" +…

kuemme01
- 472
- 5
- 19
1
vote
0 answers
Random hang by macOS task/process when specifying stderr pipe
Note: This is believed to be similar to cURL through NSTask not terminating if a pipe is present, on which I recently placed a 200 point bounty. I'm posting here in order to provide additional details of my own case.
When pasted into the swift REPL…

Peter Alfvin
- 28,599
- 8
- 68
- 106
1
vote
0 answers
get output of nstask not full when format with xml
I want to get output of a NSTask. When the output format is Text, it is full. But when the output format is XML, it is truncated.
Text format:
NSMutableArray *cmdStrings = [[NSMutableArray alloc] initWithArray:@[@"pmd", @"cpd", @"--language",…

Sugite
- 41
- 4
1
vote
0 answers
Process class not working in swift 3
For some reason the Process class is not registering as apart of the Foundation import even though it is clearly stated Here in the Apple Swift language API Library that the Process class is a part of Foundation.
For example:
import Foundation
let…

Garret Kaye
- 2,412
- 4
- 21
- 45
1
vote
2 answers
Running /bin/ps with NSTask with App Sandboxing enabled
I have a cocoa app that needs to get a list of processes. After enabling app sandboxing, I get /bin/ps: Operation not permitted. Is there another way of doing this that's compatible with app sandboxing? I am running this via NSTask

denniss
- 17,229
- 26
- 92
- 141
1
vote
0 answers
xcodebuild: cdtool cannot compile: DataModelCompile /path/to/coredatamodel.xcdatamodeld dyld: Symbol not found: _OBJC_CLASS_$_OS_object
I'm building a Mac Desktop/Cocoa Application to archive my iOS project, the core implementation uses NSTask with xcodebuild command, followed by raywenderlich's this guide.
The root cause is the CoreData model file compile, I used this app to build…

Itachi
- 5,777
- 2
- 37
- 69
1
vote
1 answer
How can you get information such as, users window for example using the NSTask class in Swift, for OSX apps?
If I can explain my self better knowing if a user is running some particular program such as word or chrome, etc.
I will try to update my question as I write code or find more information.
Thank you (:

Mage
- 195
- 1
- 2
- 12
1
vote
1 answer
NSTask with bash script problem
For example, i have this simple bash script:
#!/bin/sh
cd $1;
And this cocoa wrapper for it:
NSTask *cd = [[NSTask alloc] init];
NSString *testFolder = [NSString stringWithString:@"/Users/test/Desktop/test 1"];
[cd setLaunchPath:@"/bin/sh"];
[cd…

nukl
- 10,073
- 15
- 42
- 58
1
vote
1 answer
Can't run Apple script from command-line application
I created a command-line application for Mac OS without the GUI. This application is located at /usr/local/bin. And in some cases I need to execute Apple Script within that application. To do this, I create an NSTask and trying to run the following…

Emmett
- 464
- 5
- 11
1
vote
0 answers
Mac OS X - Calling nested Shell & Ruby scripts from Swift Cocoa desktop application
I'm trying to build a GUI application for Mac OS X [El Capitan 10.11.1] using Swift [swift --version prints: Apple Swift version 1.2 (swiftlang-602.0.53.1 clang-602.0.53)], which is able to use my shell and ruby scripts.
The problem I'm having is…

Elias
- 11
- 2
1
vote
3 answers
How would I run an .sh file using NSTask and get its output?
I need to run an .sh file and get its output. I need to see the setup of the file as well.
The .sh file simply runs a java app through terminal.
Any ideas? I'm truly stuck on this.....
Elijah
The server.sh file:
echo Starting Jarvis Program…

objectiveccoder001
- 2,981
- 10
- 48
- 72
1
vote
4 answers
Code problem - objective c - waiting for string value to appear in string value
task = [NSTask new];
[task setLaunchPath:@"/bin/sh"];
[task setArguments:[NSArray arrayWithObject:@"/applications/jarvis/brain/server.sh"]];
[task setCurrentDirectoryPath:@"/"];
NSPipe *outputPipe = [NSPipe pipe];
[task setStandardInput:[NSPipe…

objectiveccoder001
- 2,981
- 10
- 48
- 72
1
vote
0 answers
Syntax highlighting with rouge in kramdown using NSTask
I'm writing a small markdown editor for OS X. So far I can convert the markdown to HTML and get it appearing in my web view. What I haven't managed yet is to get syntax-highlighting up and running. I'm using kramdown to do the markdown -> HTML bit,…

Paul Patterson
- 6,840
- 3
- 42
- 56