nstask

NSTask character output to NSTextField unbuffered as continuous stream

╄→гoц情女王★ 提交于 2019-12-11 03:32:50
问题 What I want to accomplish is to start a command line (CL) task (wrapped NSTask) and pipe (NSPipe) the character output through an NSTextField label in my UI, in real-time as a stream of characters. The purpose of the textfield is not to capture the output in any way, or even allow it to be read. It’s just to display it, partly as a UI decoration and partly as a kind of progress indicator. I want the user to see a stream of characters just flowing by (fast) as the CL task does its work. I know

How to pass arguments to /bin/bash? [closed]

孤者浪人 提交于 2019-12-11 02:59:00
问题 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 5 years ago . In my terminal, I do $ myprogram myfile.ext . I want to be able to do the same via the command /bin/bash , but it is not working. I tried $ /bin/bash -c -l myprogram myfile.ext but it is not working. It seems that my program is launched but without my file.ext as an option (as an input file) Does anyone has a

RSYNC Directories vs Files

∥☆過路亽.° 提交于 2019-12-08 23:04:38
I'm trying to put together a little RSync program for the hell of it, and I managed to get it to work with the code below. The only problem is that it only Rsyncs single files and not directories. If you run rsync through the terminal command it can copy entire directories into other directories. Anyone know a fix? NSString *source = self.source.stringValue; NSString *destination = self.destination.stringValue; NSLog(@"The source is %@. The destination is %@.", source, destination); NSTask *task; task = [[NSTask alloc] init]; [task setLaunchPath:@"/usr/bin/rsync"]; NSArray *arguments;

Xcode 8 extension executing NSTask

故事扮演 提交于 2019-12-08 16:09:45
问题 My goal is to create an extension that executes clang-format. My code looks something like this: - (void)performCommandWithInvocation:(XCSourceEditorCommandInvocation *)invocation completionHandler:(void (^)(NSError * _Nullable nilOrError))completionHandler { NSError *error = nil; NSURL *executableURL = [[self class] executableURL]; if (!executableURL) { NSString *errorDescription = [NSString stringWithFormat:@"Failed to find clang-format. Ensure it is installed at any of these locations\n%@"

How can you get information such as, users window for example using the NSTask class in Swift, for OSX apps?

。_饼干妹妹 提交于 2019-12-08 08:50:51
问题 If I can explain my self better knowing if a user is running some particular program such as word or chrome, etc. I will try to update my question as I write code or find more information. Thank you (: 回答1: You don't have to go through NSTask , you can use Cocoa's NSWorkspace to get the list of running applications: import Cocoa let apps = NSWorkspace.sharedWorkspace().runningApplications It returns an array of NSRunningApplication objects. Let's say you want the running applications names in

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

左心房为你撑大大i 提交于 2019-12-08 04:01:25
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 http server. HTTP_SERVER_LIBS=lib/org.mortbay.jetty.jar PROGRAMD_CLASSPATH=$SERVLET_LIB:$ALICE_LIB:$JS

RSYNC Directories vs Files

 ̄綄美尐妖づ 提交于 2019-12-08 03:25:43
问题 I'm trying to put together a little RSync program for the hell of it, and I managed to get it to work with the code below. The only problem is that it only Rsyncs single files and not directories. If you run rsync through the terminal command it can copy entire directories into other directories. Anyone know a fix? NSString *source = self.source.stringValue; NSString *destination = self.destination.stringValue; NSLog(@"The source is %@. The destination is %@.", source, destination); NSTask

Ignoring user input while waiting for a task - Objective-C

女生的网名这么多〃 提交于 2019-12-08 03:15:36
问题 I have an app with a button 'convert'. When I click this button, the app starts a new process using NSTask and then greys out the button until the process finishes. My problem is, the app saves any clicks made by the user while it is waiting for the process to finish. So even though the button is grayed out, the user can click it and the process will immediately start again as soon as it finishes. I'm waiting for the process to finish using: [task waitUntilExit]; How do I ignore any user

NSTask Question

三世轮回 提交于 2019-12-08 03:00:06
问题 I'm trying to get my NSTask to unzip a file for me. This works fine if the path has no spaces, but when it does, it can't find any of the files. I can't hardcode the " signs because I'm storing the zip file in a temporary folder, which is assigned by the system. Does anyone know how to achieve this? Here's my code: NSTask*task = [[NSTask alloc] init]; [task setLaunchPath:@"/usr/bin/unzip"]; NSArray*arguments = [NSArray arrayWithObjects:zipPath,@"-d",path,nil]; [task setArguments:arguments];

sudo chmod command from cocoa

你离开我真会死。 提交于 2019-12-07 23:00:00
问题 I would like to the run the following command from my Cocoa project. (hides the spotlight icon) sudo chmod 600 /System/Library/CoreServices/Search.bundle/Contents/MacOS/Search I have found two ways how to call the command and get the following output 1) Using NSTask NSTask *writeTask = [[NSTask alloc] init]; [writeTask setLaunchPath:@"/bin/chmod"]; [writeTask setArguments: @[@"755",@"/System/Library/CoreServices/Search.bundle/Contents/MacOS/Search"]]; [writeTask launch]; >>chmod: Unable to