nstask

How to run a command in terminal from my Cocoa app?

杀马特。学长 韩版系。学妹 提交于 2020-01-02 09:55:45
问题 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 anywhere. This is the command i want to run: instruments -t /Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.xrplugin/Contents/Resources/Automation.tracetemplate -w "iPad Retina (7.1 Simulator)" ""

NSTask, command line tools and root

ぐ巨炮叔叔 提交于 2020-01-01 09:43:14
问题 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 looked at several solutions on StackOverflow. The simplest to implements seemed to me this one http://www.sveinbjorn.org/STPrivilegedTask Problem is that my NSTask makes some complex read/write operations (not present in STPrivilegedTask) and does not

NSTask and NSPipe example to comunicate with the command line objective-c

眉间皱痕 提交于 2020-01-01 06:39:32
问题 Can someone show a quick example on how to use NSTask and NSPipe in conjunction to do this: Charlie AI - run through terminal to comunicate with the AI I want to create a nice GUI for it using xcode and objective c. I want to have 2 NSTextFields for the charlie's response and user input. Then have a send button to send the user input to the command line, then get the charlie's response and post it in the NSTextField. I can handle the GUI stuff (NSTextField, ect.) But I need help with the

NSTask and NSPipe example to comunicate with the command line objective-c

99封情书 提交于 2020-01-01 06:37:05
问题 Can someone show a quick example on how to use NSTask and NSPipe in conjunction to do this: Charlie AI - run through terminal to comunicate with the AI I want to create a nice GUI for it using xcode and objective c. I want to have 2 NSTextFields for the charlie's response and user input. Then have a send button to send the user input to the command line, then get the charlie's response and post it in the NSTextField. I can handle the GUI stuff (NSTextField, ect.) But I need help with the

NSTask or equivalent for iPhone [closed]

狂风中的少年 提交于 2019-12-28 03:10:05
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 4 years ago . 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 be a resource in my app's bundle, is not allowed. Has anyone

Executing shell commands with NSTask - Objective-C Cocoa

心不动则不痛 提交于 2019-12-28 02:44:10
问题 I have been searching for days and hours for this, I have seen a lot of examples of this, but cannot figure out how NSTask works, let's say I wanted to execute the command killall Dock or defaults write com.apple.Finder AppleShowAllFiles YES something like that, how would I go about doing this. I know how to execute an external shell script (sh) but need to be more sophisticated and use NSTask instead. Thanks for any help!! 回答1: You could do something like: NSTask *task = [[NSTask alloc] init

Detecting whether a process starts and finishes with notifications in cocoa

走远了吗. 提交于 2019-12-25 16:40:36
问题 I was wondering if there was a way that I could get notifications of when a system process from /usr/sbin starts and finishes. Is it possible to attach NSTask to the running process without launching a new one? Preferably without polling please :! 回答1: For UI process you can use NSRunningApplication. You can observe the "terminated" property to know when it finishes. You can listen to NSWorkspaceWillLaunchApplicationNotification to know when an application will be launched. Since you're not

NSTask Launch causing crash

旧时模样 提交于 2019-12-24 08:35:25
问题 I have an application that can import an XML file through this terminal command : open /path/to/main\ app.app --args myXML.xml This works great with no issues. And i have used Applescript to launch this command through shell and it works just as well. Yet when try using Cocoa's NSTask Launcher using this code : NSTask *task = [[NSTask alloc] init]; [task setLaunchPath:@"/usr/bin/open"]; [task setCurrentDirectoryPath:@"/Applications/MainApp/InstallData/App/"]; [task setArguments:[NSArray

NSTask waitUntilExit hanging app on jailbroken iOS

本秂侑毒 提交于 2019-12-24 02:27:51
问题 So I've got NSTask to run a script which generates a list of something, into a txt, which I read from. But if I use my current code (below), the alert pops up before the NSTask is finished, thus resulting in a blank alert. I've tried waitUntilExit but that makes the button that invokes this action freeze, but the UI doesn't lock up itself. - (void) runSupported { stask = [[NSTask alloc] init]; [stask setLaunchPath:@"/bin/bash"]; NSString *script; script = [[[NSBundle mainBundle] bundlePath]

NSTask Race Condition With ReadabilityHandler Block

ぐ巨炮叔叔 提交于 2019-12-24 01:13:25
问题 Basic Setup I use NSTask to run a process that optimizes images. This process writes output data to stdout . I use the readabilityHandler property of NSTask to capture that data. Here is the abbreviated setup: NSTask *task = [[NSTask alloc] init]; [task setArguments:arguments]; // arguments defined above NSPipe *errorPipe = [NSPipe pipe]; [task setStandardError:errorPipe]; NSFileHandle *errorFileHandle = [errorPipe fileHandleForReading]; NSPipe *outputPipe = [NSPipe pipe]; [task