NSTask Class on OS X API , lets you run another program as a subprocess and monitor that program’s execution
Questions tagged [nstask]
459 questions
0
votes
0 answers
How check if output of bash script contains a certain string in Objective-C?
I would like to do something if the output of a shell script contains the string "Caddy 2 serving static files on :2015". This is what I have so far but the beach ball is just spinning. It seems it is because of the last command in my bash script…

aronsommer
- 123
- 1
- 11
0
votes
1 answer
Can't pass command line arguments to an NSTask running the PHP CLI
Edit: [Solved] see below.
I'm launching PHP as an NSTask and trying to pass some command line options to it:
NSTask *php = [[NSTask alloc] init];
[php setLaunchPath: phpPath];
NSArray *args = [[NSArray alloc] initWithObjects: @"-r 'echo 123;'",…

Petruza
- 11,744
- 25
- 84
- 136
0
votes
0 answers
NSTask unzip skipped filename with special characters ( å, ä, ö )
HI I'm new to mac development.
I'm using NSTask to unzip files. When unzip encounters image names with special characters ( å, ä, ö ), the files gets skipped.
Is there an encoding that I need to specify or if someone can point me to the issue that…

Lance
- 19
- 7
0
votes
0 answers
Reading NSTask output persistent memory usage
I have a simple NSTask which runs a shell command, and a NSPipe file handle for reading which is used to read the output of the command and writes out to a file. When this command terminates and the output is written to file, Activity Monitor and…

DannyBoi8181
- 33
- 4
0
votes
0 answers
Variable in NSTask - Objective-C Cocoa
I want to use command line in Cocoa for record of the password in a bunch of keys.
But I can't insert a variable at line. How to make it?
How $pass to provide me self.PassKey?
self.PassKey = [_PassTextField stringValue];
NSTask *taskPass = [[NSTask…

Сергей Галан
- 1
- 1
0
votes
1 answer
How to run the "Purge" command through NSTask?
I'm making a free Mac app that is simply a wrapper over the "purge" command that can be run in Terminal. I'm tired of the ripoffs that are populating the Mac App Store and I just want to help people. I've got the GUI finished I just can't figure…

Yep
- 653
- 5
- 20
0
votes
0 answers
I am getting EXC_GUARD when launching app using NSTask launchedTaskWithLaunchPath
Faulting code:
myTask = [NSTask launchedTaskWithLaunchPath: appPath arguments: initArray];
Where myTask is a global static NSTask* myTask = NULL; and initArray is a global static NSMutableArray *initArray = NULL; and appPath is a local…

Monika Nainwal
- 11
- 1
0
votes
0 answers
Could NSTask call a bash shell that having a read command in it and waiting for an input value?
I'm developing a macOS App which should use Process to run a shell script. The function somehow like this:
func shellDemo(launchPath: String?, args: [String]?, onComplete: RunShellScriptResult? = nil, onFail: RunShellScriptResult? = nil) -> Void {
…

boog
- 1,813
- 3
- 18
- 21
0
votes
0 answers
Use NSTask To Run SH Script in Objective C slower than direct execute script from Terminator
I created a sh/Python script as execute file. However, when I run this script by one click button from Objective C program using NSTask the progress time is much slower than I execute script directly from MacOS Terminal.
I read some information from…

Jacky Le
- 51
- 9
0
votes
0 answers
NSTask launch crash due to EXC_GUARD
In my macOS app I launch the ffmpeg task in order to retrieve the media file information.
And I receive many crashes due to EXC_GUARD:
Exception Type: EXC_GUARD
Exception Codes: 0x4000000200000001, 0xd71a2ae8e8dab339
Exception Subtype: …

Viktoriia
- 71
- 6
0
votes
1 answer
Run NSTask synchronously
I have an .app file that I'm running through NSTask and I wish the thread to be blocked till .app execution is over.
My current code is:
NSTask *task = [[NSTask alloc] init];
task.launchPath = @"/bin/bash";
task.arguments = [NSArray…

Avi L
- 1,558
- 2
- 15
- 33
0
votes
2 answers
Use a relative path with NSTask Arguments in Objective-C
I have virtually no programing experience beyond shell scripting, but I'm in a situation where I need to call a binary with launchd and because of security changes in Catilina, it looks as though it cannot be a AppleScript .app, Automator .app, or a…

peet
- 5
- 2
0
votes
1 answer
Running multiple NSTasks consecutively
I need to run multiple commands in sequence using NSTask and was wondering what would be a good way to tell if a task has finished so I can continue on to the next command. I'm using "sox" (which I am including in my application bundle) to create…

minimalpop
- 6,997
- 13
- 68
- 80
0
votes
1 answer
How to run the "screen" command from NSTask?
I want to monitor a virtual COM port (Arduino RFID) on my Mac. I can run "screen /dev/tty.serialnumber" from the terminal, and it outputs the RFID serial number when I swipe it.
As soon as I try it from Xcode with an NSTask I get the following…

Justin
- 1
0
votes
1 answer
Objective-C, best way to handle NSTask that isn't finished
I have an asynchronous dispatch queue which reads data from large files in the background. During the course of that it does a few other things including some NSTask operations. The problem I'm facing is that I populate some variables with the…

Joe Habadas
- 628
- 8
- 21