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
5
votes
0 answers

Launch application with arguments with NSWorkspace not working

I would like to open FileZilla (ftp application) with an argument. It is working with NSTask (aka. Process): let process:Process = Process() process.launchPath = appURL.path process.arguments = ["ftp://1.2.3.4"] process.launch() It is not working…
Daniel
  • 1,473
  • 3
  • 33
  • 63
5
votes
2 answers

NSTask /bin/echo: /bin/echo: cannot execute binary file

I am making an OS X App that requires running an shell script. Here are my swift code: func runTask(arguments: [String]) { output.string = "" task = NSTask() task.launchPath = "/bin/bash" task.arguments = arguments; errorPipe =…
Tom Shen
  • 1,838
  • 3
  • 19
  • 40
5
votes
2 answers

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

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…
Kornel
  • 97,764
  • 37
  • 219
  • 309
5
votes
2 answers

Calling Gnuplot in Swift

I'm trying to call gunplot from swift to produce some plots in .png. However, the program below does not work --- the resulting 1.png file is empty. If I leave the "set term aqua" though, it does call the aqua window with the plot in it. However…
Yrogirg
  • 2,301
  • 3
  • 22
  • 33
5
votes
0 answers

Sandboxed child process launced with NSTask fails silently

I'm building an OS X app that contains a command-line executable. The app calls the executable, passing along a filename that was chosen by the user, and grabs the output with a pipe. The code for doing this looks something like this: let bundle =…
Jack Nutting
  • 606
  • 3
  • 11
5
votes
1 answer

How to execute a shell command with root permission from swift

I am new on Swift and I am trying to create a very simple application that executes a root shell command when you press a round button. I have found the following link online, that explains how to execute a shell command with user permission on…
merch
  • 945
  • 8
  • 19
5
votes
1 answer

Run "launchctl" command under specific user using NSTask in OS X

My application is launching under root and I need to be able to unload processes using NSTask and launchctl Here is a code I do: NSPipe *pipe = [NSPipe pipe]; NSTask *task = [[NSTask alloc] init]; [task setLaunchPath:…
Serge
  • 2,031
  • 3
  • 33
  • 56
5
votes
1 answer

Terminate an NSTask and its children

I'm using NSTask to execute a series of long running commands like so: commandToRun = @"command 1;command2"; NSArray *arguments = [NSArray arrayWithObjects: @"-c", commandToRun, …
stdout
  • 1,761
  • 1
  • 18
  • 33
5
votes
1 answer

NSTask subprocess stuck in _dyld_start

I use NSTask to run my helper application. On 99% one my customer systems this works fine, but two got back to me letting me know it doesn't. One of them was nice enough to let me look into the issue per remote desktop. I tried a lot of different…
catlan
  • 25,100
  • 8
  • 67
  • 78
4
votes
1 answer

Trying to use cydia libraries: NSTask on Jailbroken iphone crashes with Segmentation fault: 11

I want to run dpkg ( or any other binary library files from cydia in the /bin or /usr/bin directories) from a GUI app with an icon, like mobileterminal, ifile, myfile, cydia, alertscript, and so many others can. How do they accesses the libraries?…
apple16
  • 1,137
  • 10
  • 13
4
votes
3 answers

How to run NSTask with multiple commands

I'm trying to make a NSTask running a command like this: ps -clx | grep 'Finder' | awk '{print $2}' Here is my method - (void) processByName:(NSString*)name { NSTask *task1 = [[NSTask alloc] init]; NSPipe *pipe1 = [NSPipe pipe]; [task1…
dhrm
  • 14,335
  • 34
  • 117
  • 183
4
votes
1 answer

Sandbox with NSTask

I have sandboxing enabled and use /sbin/ping with NSTask: [task setLaunchPath:@"/sbin/ping"]; [task setArguments:[NSArray arrayWithObjects:@"-c10", iPAddress, nil]]; Everything works great and I get the expected output. I also want to use…
Daniel
  • 1,473
  • 3
  • 33
  • 63
4
votes
1 answer

Sending ETX to NSTask

I have an NSTask that's executing another program I wrote. In that command line program, it expects the ETX (control-C, or ASCII value 3) to pause one of its processes and call another function. How can I send this? I know I'm sending commands…
Raphael
  • 43
  • 2
4
votes
1 answer

Best way to attach GDB to process ID and list its ARM registers on the iPhone?

Just wondering, what is the most reliable/best way to attach GDB to process ID and list its ARM registers on the iPhone (through a cocoa app)? I've been trying NSTask for quite awhile, it is able to list the x86 registers of a specific process…
Jared Aaron Loo
  • 668
  • 1
  • 10
  • 18
4
votes
1 answer

Pass data into a tool's stdin using NSTask

Let's say I have some tool that, at some point in its execution, asks for user input. For example, it might ask for name and address. At another point it might ask for a password (and retyping of the password). Is it possible for NSTask and NSPipe…
Enchilada
  • 3,859
  • 1
  • 36
  • 69