---
title: "execute(withArguments:completionHandler:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/nsuserunixtask/execute(witharguments:completionhandler:)"
---

# execute(withArguments:completionHandler:)

Execute the unix script with the specified arguments.

## Declaration

```swift
func execute(withArguments arguments: [String]?, completionHandler handler: NSUserUnixTask.CompletionHandler? = nil)
```

```swift
func execute(withArguments arguments: [String]?) async throws
```

## Parameters

- `arguments`: An array of NSString objects 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 doc://com.apple.foundation/documentation/Foundation/NSUserUnixTask/CompletionHandler.

## Discussion

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.

## See Also

### Related Documentation

- [standardOutput](foundation/nsuserunixtask/standardoutput.md)
- [standardError](foundation/nsuserunixtask/standarderror.md)
- [init(url:)](foundation/nsuserscripttask/init(url:)-2qgls.md)
- [standardInput](foundation/nsuserunixtask/standardinput.md)
