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
Error passing NSString argument to NSTask
I am trying to schedule a shutdown event with pmset executed via NSTask in OSX app.
NSCalendar *cal = [NSCalendar new];
NSDate *dateNext = [date dateByAddingTimeInterval:120];
NSDateFormatter *df = [[NSDateFormatter alloc] init];
[df…

MobileCushion
- 7,065
- 7
- 42
- 62
0
votes
1 answer
Using NSTask as root - error: "launch path not accessible"
For some reason when I'm attempting to run a task via NSTask I receive the error message: "launch path not accessible".
My app is running as root. And if I type the EXACT same command in terminal, it runs fine, so I'm a bit confused.
My application…

Geesu
- 5,928
- 11
- 43
- 72
0
votes
0 answers
Issue using filename having space as argument in NSTASK (objective-c)
I am trying to pass argument having space in the foldername to NSTASK. However, the command is not executed successfully, but when i try to do it manually on commandline, it works fine.
NSMutableString* archive_path=[[NSMutableString alloc]init];
…

Emad mohd
- 33
- 5
0
votes
1 answer
xcrun via NSTask: how to get return value in same form as in Terminal?
I'm building an app that automates notarization of my apps.
I ran into the following issue:
When I use NSTasks to perform commands such as xcrun altool and xcrun stapler, the return value is much longer than what I get in Terminal.
For example,…

Leo Braun
- 324
- 2
- 9
0
votes
1 answer
How to execute `aerender` command line tool via NSTask/Process?
I'm trying to build a proof of concept macOS application to render an Adobe After Effects project file by executing aerender command line tool via NSTask/Process but not having much success.
var task: Process = Process()
func render()
let…

Sean Howard
- 11
- 4
0
votes
1 answer
How to run NSTask or a subprocess as a different user on macOS
I have a program that runs as the root user (getuid() returns 0).
I need to execute a command line tool as the user that's currently logged in (which I can determine by getting the HOME env var). (See below for an elaboration)
How do I do that,…

Thomas Tempelmann
- 11,045
- 8
- 74
- 149
0
votes
1 answer
Getting stdout from Process (NSTask) sometimes fails
I have a wrapper function around Process to easy call some external procedures (similar to pythonic check_output):
struct Output {
public var code: Int32
public var stdout: String
public var stderr: String
}
func env(workingDir: String,…

Alfred Zien
- 1,025
- 1
- 11
- 31
0
votes
1 answer
How to pass source and destination path in NSTask arguments for LZip?
I am trying to Unarchive the Lzip file so using NSTask to achieve it
[task setArguments:@[@"-k",@"-d",source,destination]]; these are the arguments which i was passing but extraction always happens in source path folder .
Any suggestions ?
Thanks…

osxDev123
- 21
- 4
0
votes
1 answer
SDK with mixed shell and Objective C components
Relatively new here so please excuse the dumb question.
I'm currently working with a specific set of commercial DSLR-type cameras (Phase One), and have an SDK provided by the manufacturer. However, there are two components to the SDK - one is…

ABC
- 3
- 2
0
votes
0 answers
Run periodic tasks in the background after app terminates in MacOS
I am an iOS developer and I have developed an app that runs a periodic background task using Background Modes, I want to implement the same feature in the MacOS version of this app, as I am new to the MacOS development, I am facing some issue…

Anshuman Singh
- 1,018
- 15
- 17
0
votes
2 answers
Trying to run NSTask but getting an error
I have a standalone (3rd party) app that I'm trying to launch using a command "kick". I've setup my ~/.bash_profile and /etc/bashrc files so that I can type kick [command] into a terminal window and it works perfectly. So I'm assuming that I have…

crewshin
- 765
- 9
- 22
0
votes
0 answers
Why does my Swift code work in playground but not in the real cocoa app?
I'm currently trying to automate things in a macOS status bar application.
Now I had tried to make the Kerberos Login in a Process (previous called NSTask). In my playground, the code creates successfully the token. But when I move the code to the…

MOE
- 769
- 6
- 19
0
votes
0 answers
Can't Call Salesforce DX from NSTask
From the Terminal, I can call all of the Salesforce DX CLI commands and functions. For example, "sfdx force:doc:commands:list" will show all the commands. BUT from the NSTask code (below) on a mac, I cannot call the Salesforce DX CLI at all. The…

Bill Appleton
- 101
- 3
0
votes
0 answers
how to readData from NSTask(Process)
@IBAction func startLocalAction(_ sender: NSButton) {
cmd(cmdStr: ["-c","cd Desktop;ls;git clone https://github.com/Fidetro/Masonry"])
}
@objc func receivedData(notification:NSNotification) {
let fileHandle = notification.object
if let…

Karim
- 322
- 4
- 20
0
votes
0 answers
Command fails via NSTask but runs via system()
I am trying to install a software. I tried running a script which calls
installer -pkg /path/to/software.pkg -target /
when i try calling the script via objective-c code like
NSTask *task;
task = [[NSTask alloc] init];
[task…

R.Srinath
- 21
- 1
- 6