nstask

NSTask executed only once

本秂侑毒 提交于 2019-12-23 16:19:05
问题 I'm having trouble executing different NSTask's. Same launchPath , different arguments . I have a class who's instances administer own NSTask objects and depending on arguments those instances were initialized with - dependent NSTask object is being created. I have two initializers: // Method for finished task - (void)taskFinished:(NSNotification *)aNotification { [myTask release]; myTask = nil; [self createTask]; } // Designated initializer - (id) init { self = [super init]; if (self != nil)

How would I run an .sh file using NSTask and get its output?

只愿长相守 提交于 2019-12-23 03:04:03
问题 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 D. ALICE_HOME=. SERVLET_LIB=lib/servlet.jar ALICE_LIB=lib/aliceserver.jar JS_LIB=lib/js.jar # Set SQL_LIB to the location of your database driver. SQL_LIB=lib/mysql_comp.jar # These are for Jetty; you will want to change these if you are using a different

How to safely use [NSTask waitUntilExit] off the main thread?

馋奶兔 提交于 2019-12-22 09:18:31
问题 I have a multithreaded program that needs to run many executables at once and wait for their results. I use [nstask waitUntilExit] in an NSOperationQueue that runs it on non-main thread (running NSTask on the main thread is completely out of the question). My program randomly crashes or runs into assertion failures, and the crash stacks always point to the runloop run by waitUntilExit , which executes various callbacks and handlers, including—IMHO incorrectly—KVO and bindings updating the UI,

Using NSTask and NSPipe causes 100% CPU usage

百般思念 提交于 2019-12-22 04:39:21
问题 I'm trying to run a simple bash script using NSTask and direct the output to a text view. Once the task is executed, the CPU usage of my app is 100%, even though it's a simple echo (for now). I created a completely fresh project to isolate the issue: @interface AppDelegate () @property (nonatomic) NSTask *task; @property (nonatomic) NSPipe *pipe; @end @implementation AppDelegate - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { self.pipe = [NSPipe pipe]; self.pipe

How to use NSTask run terminal commands in loop in consistent environment?

蹲街弑〆低调 提交于 2019-12-21 06:27:18
问题 I want to use NSTask to simulate the Terminal to run commands. The codes as follows. It can get input in loop and return the process output. int main(int argc, const char * argv[]) { @autoreleasepool { while (1) { char str[80] = {0}; scanf("%s", str); NSString *cmdstr = [NSString stringWithUTF8String:str]; NSTask *task = [NSTask new]; [task setLaunchPath:@"/bin/sh"]; [task setArguments:[NSArray arrayWithObjects:@"-c", cmdstr, nil]]; NSPipe *pipe = [NSPipe pipe]; [task setStandardOutput:pipe];

Swift NStask function

你说的曾经没有我的故事 提交于 2019-12-13 11:20:48
问题 I'm a complete swift noob. Using this code in xcode I get the result I need. I created a command line binary "menubar" that takes several arguments. I normally run it in the terminal "/bin/menubar getip", "/bin/menubar/getuser". I want to create a function based on the following working code. import Cocoa import Foundation var task:NSTask = NSTask() var pipe:NSPipe = NSPipe() task.launchPath = "/bin/menubar" task.arguments = ["getip"] task.standardOutput = pipe task.launch() var handle = pipe

NSTask string encoding problem

為{幸葍}努か 提交于 2019-12-13 06:49:47
问题 In my program, I'm grep-ing via NSTask. For some reason, sometimes I would get no results (even though the code was apparently the same as the command run from the CLI which worked just fine), so I checked through my code and found, in Apple's documentation, that when adding arguments to an NSTask object, "the NSTask object converts both path and the strings in arguments to appropriate C-style strings (using fileSystemRepresentation) before passing them to the task via argv[]" (snip). The

How to run an executable in iOS App?

血红的双手。 提交于 2019-12-12 05:00:51
问题 I want to run an executable file in my iOS app. (or execute some command line commands) I think this can be done with the help of NSTask, but that doesn't seem to be available in iOS (its available for mac OS X only). So, How can i run an executable from my app ? OR How can i execute shell commands from my app ? How can i make use of NSTask in iOS ? Are there any other libraries like NSTask which i can make use of ? If none of the above is possible, please let me know a way around. I want my

Using awk with NSTask

久未见 提交于 2019-12-12 04:31:24
问题 How would I use this awk command: awk 'NR>1{print $1}' string-to-modify with NSTask? I already tried setting /usr/bin/awk as the launch path, 'NR>1{print $1}' as an argument, then the string to modify as another argument but all I get is this: /usr/bin/awk: syntax error at source line 1 context is >>> ' <<< /usr/bin/awk: bailing out at source line 1 Any help would be appreciated :) 回答1: First, remove single quotes: NSTask doesn't invoque a shell which could interpret them. This is the cause

Disabling Mission Control, Spaces, Dashboard and any other external process

偶尔善良 提交于 2019-12-12 03:14:48
问题 I was wondering if it was possible to (for a short period of time) disable and re-enable external processes to an application like Mission Control, Spaces, Expose, Dashboard, etc... within an application, while still allowing the user to use my application? A way of accomplishing this I found was to use NSTask to disable the processes with the corresponding terminal command. For Example: - (NSString *)runCommandWithBase:(NSString *)base arguments:(NSArray *)arguments { //Create the task