Questions tagged [nstask]

NSTask Class on OS X API , lets you run another program as a subprocess and monitor that program’s execution

459 questions
2
votes
1 answer

Run a shell command on Objective c and simultaneously get output

Let's say I want to run curl -o http://example.com/file.zip via an Objective C app and I want to have a label or text box containing the download status which gets updated while the command is running. Maybe this could be achieved using…
2
votes
0 answers

How to terminate all threads reading from Pipe (NSPipe) related to Process (NSTask)?

I am writing a MacOS/Cocoa app that monitors a remote log file using a common recipe that launches a Process (formerly NSTask) instance on a background thread and reads stdout of the process via a Pipe (formally a NSPipe) as listed below: class…
wcochran
  • 10,089
  • 6
  • 61
  • 69
2
votes
0 answers

NSTask with no dock icon for child processes

I am trying to create a simple launcher application on the Mac. I am able to set LSUIElement = 1 on the parent application, but child processes launched from the application appear in the Dock when launched. Is there a way that I can prevent an icon…
jocull
  • 20,008
  • 22
  • 105
  • 149
2
votes
1 answer

read ASCII progress bar of NSTask

In a little app, I'm running a terminal command, drutil erase. I'm using a NSTask. When you execute this command in Terminal, it will show you an ASCII progress bar which is continuously updated. However, I'm not able to read this information in my…
2
votes
1 answer

Swift script works directly inside Xcode Run Script phase, but not via external file due to NSTask/Process

I have Swift script: #!/usr/bin/env xcrun --sdk macosx swift import Foundation let task = Process() // other stuff The Process() is causing a problem. If I remove Process(), it works. Further, if I paste the Swift code into the Run Script phase…
abc123
  • 8,043
  • 7
  • 49
  • 80
2
votes
1 answer

using open command with NSTask

I have a pretty basic understanding of NSTask in Swift and can run a few commands in my program, but when I run open it says the file does not exist. I added the exact arguments that I use in the terminal, and I don't know what I'm missing. This is…
Jean
  • 21
  • 1
2
votes
2 answers

Swift 2.1 OSx shell commands using NSTask work when run from xcode, but not when exported

I wrote a simple OSx (10.11) application to execute shell commands when a button is pressed. It works when I run it from xcode, but when I export the application via "archive", one of the buttons no longer works. I don't get an error and I don't get…
AllenMoh
  • 476
  • 2
  • 13
2
votes
2 answers

NSTask output buffer size issue (Running SPApplicationsDataType command )

Try to read some information from system profiler. For this purpose i m running some terminal line commands with NSTask. If i run some command which output not too big there is no problem.(For example : SPInstallHistoryDataType) But if i run…
2
votes
0 answers

NSTask Output to Text View Sometimes Goes to Console

Directing the output of an NSTask object to a text view works for most of the commands I've tried, but not for a git clone. In that instance, the output goes to the Xcode console, even though I have no print statements in my code. The code as…
rdelmar
  • 103,982
  • 12
  • 207
  • 218
2
votes
1 answer

Restart Dock from app

I have an app that needs to restart the dock application. I have tried this with both Apple Script: var errorDict: NSDictionary? = nil let appleScript = NSAppleScript(source: "tell application \"Dock\" to quit") var error =…
Paul Peelen
  • 10,073
  • 15
  • 85
  • 168
2
votes
1 answer

Cocoa Sandbox App: Spawn FFMPEG

I have an application which uses FFMPEG and FFPROBE to perform some tasks on a video the user can open with my application. For non-sandboxed applications everything works fine, but when my app is running in a sandbox FFPROBE doesn't seem to get…
Alex
  • 1,221
  • 1
  • 10
  • 19
2
votes
0 answers

OSX Xcode: Sandbox Error when creating DMG

I have an OSX xcode project, which works perfectly until I turn the sandbox on. Under Capabilities, I have turn on Sandbox, and File access: User Selected File - Read/Write My project is like this, when user clicks on a button, the NSSavePanel will…
Josh
  • 692
  • 2
  • 9
  • 38
2
votes
1 answer

NSTask or NSThread?

I have some code that is attached to an NSTimer. Around 5 times every second, it interacts with another application (by emulating keystrokes) and when appropriate spits out an NSNotification, that is handled by another piece of code. While the…
Ben Packard
  • 26,102
  • 25
  • 102
  • 183
2
votes
1 answer

NSTask with defaults and killall bash commands

I am trying to run the following two bash commands in a Cocoa app: defaults write com.apple.finder CreateDesktop false killall Finder Using NSTask, I have the following Swift code to execute the command when a button is clicked: let commands =…
wigging
  • 8,492
  • 12
  • 75
  • 117
2
votes
1 answer

NSNotification and Multithreading

I'm trying to get the notification NSTaskDidTerminateNotification in my multithreaded app but I can't get it working. It does seem to work when I tested it on a single threaded app. In init I have [[NSNotificationCenter defaultCenter] addObserver:…