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
1 answer
NSTask with command-line input redirection
I'm trying to learn writing a NSTask in such a way that the task process can accept input file redirection as argument. In traditional unix system() command this is trivial to code, but too far from being controllable enough for the demands of my…

user3078414
- 1,942
- 2
- 16
- 24
1
vote
1 answer
NSTask in playground
I'm wondering if NSTask is not available in playgrounds.
This does not compile
import Foundation
let task = NSTask()
Does anyone know if that's not (yet) possible or am I missing something?
Update
It's possible to create iOS or OS X playgrounds.…

benrudhart
- 1,406
- 2
- 13
- 25
1
vote
2 answers
osx swift pass path with space as argument to shell script called by NSTask
This is the code I can't get to work. If I remove the directory part with the space my shell script runs fine.
shell script simplified is : /usr/bin/find $1 -name *.txt
error with the space is binary operator expected
let bundle =…

dirk schelfhout
- 31
- 5
1
vote
1 answer
How to access a packaged CLI tool using Swift on OSX
I need to accomplish following three things. I am not sure how to go about it using Swift and Xcode
Package an existing CLI tool with the APP.
Use swift to issue commands to this CLI app and let it do its thing.
Read the output stream coming from…

Avadh B S Dwivedi
- 145
- 2
- 11
1
vote
1 answer
NSTask subclass error - launchPath only defined for abstract class
I'm trying to create a subclass of NSTask, that is augmented with a name and an activityDescription property, for the purpose of displaying status, in a UI in an OSX desktop application.
However, when I try to set the launchPath or arguments…

Sheamus
- 6,506
- 3
- 35
- 61
1
vote
1 answer
Can't do fopen when using NSTask to run an executable
What I want to do
To run an executable "server" from my Cocoa app. The executable can already run perfectly when invoked in the terminal and will read a text file in the same directory.
What I've done
Put "server" and other files in the "Supporting…

Khylnn Wu
- 19
- 5
1
vote
1 answer
Run NSTask from .command
Sorry, english is not my first language, and I have a poor grammar skill.
Hi, I am a developer that is very new to Objective-C, and I have some problems with using NSTask. I have a .command file that I want to execute in this cocoa application, but…

eshin2020
- 35
- 4
1
vote
3 answers
How to run a command in terminal from my Cocoa app?
I want to use instrument to install the .app on my iOS simulator through my cocoa app.
This is my first time developing a cocoa app and also NSTask.
NSTask requires a launch path which in my case is irrelevant as this command can be run from…

Ashutosh
- 5,614
- 13
- 52
- 84
1
vote
1 answer
Read data from NSTask Pipe as it becomes available
I have this code so far, the goal is to act on certain outputs from my NSTask. Essentially it (My NSTask) is a program that outputs strings to the console over time. I want to be able to say call a method in my cocoa Objective-C app when a certain…

Marcus
- 512
- 1
- 7
- 22
1
vote
0 answers
get charset and mimetype in objective c
In mac OS X I can get charset and mimetype of file with this command
file -I /Users/bbb/Desktop/ba.py
And this command return this result
text/x-java; charset=us-ascii
Now I want get this mime type and charset in objective c without using NSTask…

user3323552
- 61
- 8
1
vote
2 answers
Executing sh file with sudo in OS X gives an error
I've developed an application where I need to run some script under root. Also sh script contains "sudo" commands. For running sh script under root I use STPrivilegedTask class from github:
https://github.com/sveinbjornt/STPrivilegedTask
Here how I…

Serge
- 2,031
- 3
- 33
- 56
1
vote
1 answer
Change osx network configuration with NSTask
im trying to Disable Wifi, set socks proxy:ip,port,login:pass and then reenable wifi.
Im trying to perform this with
NSTask *task = [NSTask new];
[task setLaunchPath:@"/bin/sh"];
[task setArguments:@[@"-c", @"networksetup -setwebproxystate Wi-Fi…
user3949666
1
vote
1 answer
Using Authorization Services with NSTask
Ok, I am using NSTask to run a shell script that needs to be run with administrator privileges. I am using some code from this question: NSTask and AuthorizationCreate.
Here is what I currently have:
//Authorization Create
AuthorizationRef…

Sam W
- 599
- 2
- 16
1
vote
0 answers
Objective-C using print "\r$i"
I can use NSTask to grab the output of stdout, create a string and put it into an NSTextField without issue, although how would I make the output behave like print "\r$i"?
This perl script demonstrates the output:
$|++;
for ($i=0; $i<1000000; $i++)…

Richard Hoffman
- 11
- 1
1
vote
0 answers
Multiple Commands with NSTask
I want to run a shell script using NSTask. This script is designed such that it will first come out from its current operation (cd ..) then will perform other operations.
So two tasks needs to be performed using NSTask go to the directory where…

Akhil Shrivastav
- 427
- 3
- 13