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

How can I run a NSTask in the background and show the results in a modal NSWindow while running

I would like to execute a command with NSTask, and be able to see the progress in a modal window. For example if I execute 'ls -R /' i would like to see the chunks appearing in a NSTextView. I came up with the following, and everything works fine,…
Germo
  • 23
  • 3
2
votes
1 answer

How to run an executable in iOS App?

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…
Ashish
  • 355
  • 2
  • 5
  • 9
2
votes
1 answer

NSTask calling perl and piping in find not working

I'm trying to run a perl regex one liner on a bunch of files in a directory (via recursive find) and having a bit of trouble getting NSTask to do what the one line does on the command line. The perl one liner in the terminal works, and a simplified…
nflacco
  • 4,972
  • 8
  • 45
  • 78
2
votes
1 answer

Run terminal command within sandbox

I wrote a Mac app that turns Desktop icons visible/invisible. I use NSTask to run a terminal command to reset the Finder: - (void)killFinder { NSTask *killFinderTask = [[NSTask alloc]init]; NSArray *killFinderArray = [NSArray…
Standstill
  • 399
  • 4
  • 17
2
votes
1 answer

Launching command using NSTask returns error

I'd like to launch the following command from my application using NSTask: sudo -u myusername launchctl load /Library/LaunchAgents/com.google.keystone.agent.plist Here is a code I do: NSPipe *pipe = [NSPipe pipe]; NSTask *task = [[NSTask…
Serge
  • 2,031
  • 3
  • 33
  • 56
2
votes
1 answer

cocoa sandbox embedded command line not work

I have a third-party command line tool that launches from a main cocoa app which will be distributed in Mac App Store. I need to sandbox the third-party command line tool, but when I run it (with NSTask), it crashes with error “Application…
2
votes
2 answers

How to pass arguments to /bin/bash?

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…
Colas
  • 3,473
  • 4
  • 29
  • 68
2
votes
0 answers

Execute Ruby gem in Objective-C fails with NSTask

I'm trying to run a Ruby gem called Cupertino (https://github.com/nomad/cupertino) from an Objective-C app. The ios login command works fine from the terminal. When I try to run it using an NSTask, I get the following…
Ben Williams
  • 4,695
  • 9
  • 47
  • 72
2
votes
3 answers

sudo chmod command from cocoa

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…
keith.g
  • 900
  • 9
  • 19
2
votes
2 answers

Get Notification of task progress from NSTask

Any body have idea about getting notification from NSTask while NSTask is executed. I am unzipping a zip file using NSTask and need to show the unzip data progress in a NSProgressBar. I don't found any idea for doing such task.So that i show the…
Surjeet Singh
  • 11,691
  • 2
  • 37
  • 54
2
votes
0 answers

Sandboxing Application With Command-Line Tool

I'm a bit confused about sandboxing an application that uses a command-line tool (ffmpeg). I won't mention his name, but I read at least two topics at Apple's Developer Forums where an Apple person suggests that the application requires the…
El Tomato
  • 6,479
  • 6
  • 46
  • 75
2
votes
1 answer

iPhone app: get shell command output

I'm trying to build an app for the iPhone (or iPad, for that matter) in which I want to run some shell commands. The iPhone on which I want it to work is not jailbroken. The system() command seems to work in executing a shell command, but output and…
tomsmeding
  • 916
  • 7
  • 25
2
votes
3 answers

in objective-c is there any easy way to add backslash in front of special characters?

Note: Not sure why this is marked as duplicate as I clearly stated that I don't want to use stringByReplacingOccurrencesOfString over and over again. I have a question regarding the special character filename. I have implemented a program, so that…
Josh
  • 692
  • 2
  • 9
  • 38
2
votes
3 answers

NSTask returning HTTP Headers

I'm running /usr/bin/perl or /usr/bin/php via an NSTask and want to retrieve the HTTP headers of the program. I've properly formatted the environment (Perl requires env vars to be prefixed with HTTP_), but neither of the task are returning anything…
Dave DeLong
  • 242,470
  • 58
  • 448
  • 498
2
votes
1 answer

Converting shell script to Objective-C CLI

I am planning to convert a rather long shell script I have into an Objective C command line tool. I'm planning to use NSTask to run the shell commands (this is a large script, and it has several thousand copy/move/delete operations). My question is,…
indragie
  • 18,002
  • 16
  • 95
  • 164