NSUserUnixTask Class Reference
| Inherits from | |
| Conforms to | |
| Framework | /System/Library/Frameworks/Foundation.framework |
| Availability | Available in OS X v10.8 and later. |
| Declared in | NSUserScriptTask.h |
Overview
The NSUserUnixTask class is intended to run unix applications, typically a shell script, from your application. It is intended to execute user-supplied scripts, and will execute them outside of the application's sandbox, if any.
The class is not intended to execute scripts built into an application; for that, use one of the NSTask, NSAppleScript, or AMWorkflow classes. If the application is sandboxed, then the script must be in the NSApplicationScriptsDirectory folder. A sandboxed application may read from, but not write to, this folder.
If you simply need to execute unix scripts without regard to input or output, use NSUserScriptTask, which can execute any of the specific types. If you need specific control over the input to, or output from, or the error stream of the script, use this class.
Tasks
Executing the Unix Script
Standard Unix Streams
-
standardErrorproperty -
standardInputproperty -
standardOutputproperty
Properties
standardError
The standard error stream.
Discussion
Setting to nil will bind the stream to /dev/null.
The default is nil.
Availability
- Available in OS X v10.8 and later.
Declared In
NSUserScriptTask.hstandardInput
The standard input stream.
Discussion
Setting to nil will bind the stream to /dev/null.
The default is nil.
Availability
- Available in OS X v10.8 and later.
Declared In
NSUserScriptTask.hstandardOutput
The standard output stream.
Discussion
Setting to nil will bind the stream to /dev/null.
The default is nil.
Availability
- Available in OS X v10.8 and later.
Declared In
NSUserScriptTask.hInstance Methods
executeWithArguments:completionHandler:
Execute the unix script with the specified arguments.
Parameters
- arguments
An array of
NSStringobjects containing the script arguments. The arguments do not undergo shell expansion, so you do not need to do special quoting, and shell variables are not resolved.- handler
The completion handler Block that returns the result. See
NSUserUnixTaskCompletionHandler.
Discussion
This method should be invoked no more than once for a given instance of the class.
If the script completed normally, the completion handler's error parameter will be nil.
Availability
- Available in OS X v10.8 and later.
See Also
Declared In
NSUserScriptTask.hConstants
NSUserUnixTaskCompletionHandler
Implement this block to retrieve an error from the Unix scripted executed by executeWithArguments:completionHandler:.
typedef void (^NSUserUnixTaskCompletionHandler)(NSError *error);
Availability
- Available in OS X v10.8 and later.
Declared In
NSUserScriptTask.h© 2012 Apple Inc. All Rights Reserved. (Last updated: 2012-07-23)