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
0
votes
1 answer

NSPipe input from process I don't control

I have an application written in Objective-C and am trying to receive messages from an app written in C. It appears I have two options... XPC services and Piping. In regards to NSPipe - I am trying to determine how I can open a pipe that watches a…
Jon W
  • 35
  • 8
0
votes
1 answer

IBAlert output of a bash script

i use NSTask to run my bash script, works perfectly, but at the end, i want the app to make an iBAlert (esay :D) but that shows a line of the bash script (ex: Pacthing hlll... Pathing dlll... Succesfully pathed dlll,hlll (whatever)). I want the…
Cykey
  • 81
  • 1
  • 3
0
votes
0 answers

How to run code out of a string at runtime?

First of all, I know that Apple rejects apps that include something like that. It's just for the personal purpose. I tried the following example: import Foundation var instructions: String = "let str = \"Hello\"\nprint(\"\\(str) world\")\n" let…
Rainer Niemann
  • 454
  • 3
  • 16
0
votes
0 answers

Process() : - How to identify The PID of process when has been open from Process()?

I am developing osX app, I need to open another App from MyApp func openAnotherProcess(command:[String]) { let task = Process() task.launchPath = /PATH FOR WHICH WANT TO OPEN/ task.arguments = command let pipe =…
Komal Kamble
  • 424
  • 1
  • 8
  • 25
0
votes
1 answer

NSTask get notified when a command can't execute "command not found"

I'm trying to run terminal commands/scripts from my application, all is working fine however when a command is wrong and can not execute I get something like this: but this "/bin/bash: line..." string is not in my output string I get from the task,…
Steven B.
  • 1,429
  • 2
  • 19
  • 38
0
votes
0 answers

Relaunching cocoa app with command line arguments

I am trying to relaunch my application with some command line arguments. The below code works (without command line arguments) - (void)relaunchAfterDelay:(float)seconds { NSLog(@"relaunchAfterDelay ") ; NSTask *task = [[NSTask alloc] init]…
Anand Srinivasan
  • 450
  • 5
  • 20
0
votes
0 answers

Objective C - NSTask support

I am programming an advanced Executable (binary) Analyser Application that can do many operations on Mach-O binaries. One of these functions is a simple launch operation with can simply execute the executable and log its output. I recently found out…
YeaTheMans
  • 1,005
  • 8
  • 19
0
votes
1 answer

NSTask to check if process is running

I'm trying to determine if a particular process if running, and tried with NSTask but it gives me an error when I try to grep the ps command: ps: illegal argument: |. Maybe trying to use nstask for this is not the best way? Here is the my…
0
votes
1 answer

Cocoa app cannot start looping python script. Works when built/run through xcode

I'm trying to use NSTask to start a looping python script from a cocoa app. The python script ends up in the app's Contents/Resources folder. I get the path to the script and create the NSTask…
Dirk
  • 599
  • 1
  • 4
  • 18
0
votes
2 answers

Need to execute a command in Cocoa app

I am developing a macOS app using Objective-C that I want to run some commands same like terminal. Actually I want to run YOLO command from my application. I am using NSTask class for this. When I run the command through code, on task launch, I am…
idrees
  • 1
  • 1
0
votes
1 answer

See NSTask output Cocoa

How could I make an if statement that's like: if(the output of a nstask is equal to a specific string){ //do stuff over here } I'm running a NSTask and it put's out the data that's coming from it in the NSLog, but how could I not show it there…
user6342059
0
votes
1 answer

How to return NSLog output in real time as a class property in Swift

I have two classes in Swift, one is a ViewController.swift, another has some business logic, called Brain.swift. In Brain.swift I have a class which contains a function called convert() which executes an NSTask. In ViewController.swift all of the…
user43633
  • 319
  • 3
  • 7
0
votes
2 answers

Starting an SH file with NSTask

Here is my code: -(void)startTask{ NSString * cmd = @"/bin/sh"; pty_ = [[PseudoTTY alloc] init]; NSTask * task = [[NSTask alloc] init]; [task setStandardInput:[pty_ slaveFileHandle]]; [task setStandardOutput:[pty_ slaveFileHandle]]; [task…
objectiveccoder001
  • 2,981
  • 10
  • 48
  • 72
0
votes
1 answer

Running node commands in Swift

I'm trying to run nodejs commands using Swift in my OS X app. Running commands like echo work but when I'm trying to run node: func node(args: String...) -> Int32 { let task = NSTask() task.launchPath = "/usr/bin/env" task.arguments = args …
TheAbstractDev
  • 139
  • 1
  • 10
0
votes
0 answers

Swift hiding shell script

I have a simple shell script wrapper on swift project for OSX. When I build the app I can clearly see my ".sh" file in the Resources folder. I thought about renaming it and start the name of the script with a ".dot" so finder hides it but I would…
nyitguy
  • 598
  • 4
  • 18