Skip to content

Instantly share code, notes, and snippets.

@codelynx
Created November 15, 2016 12:53
Show Gist options
  • Select an option

  • Save codelynx/523826cfff0e4e8fc4b105a3697a36d7 to your computer and use it in GitHub Desktop.

Select an option

Save codelynx/523826cfff0e4e8fc4b105a3697a36d7 to your computer and use it in GitHub Desktop.
Code snippet to execute command line with arguments [Mac] [Swift]
let process = Process()
process.launchPath = "/usr/sbin/arp"
process.arguments = ["-a"]
let pipe = Pipe()
process.standardOutput = pipe
process.launch()
let output = pipe.fileHandleForReading.readDataToEndOfFile()
let outputString = String(bytes: output, encoding: .utf8)!
print(outputString)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment