Advertisement
Guest User

Untitled

a guest
Mar 25th, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. func run(_ cmd: String) -> String? {
  2. let pipe = Pipe()
  3. let process = Process()
  4. process.launchPath = "/bin/sh"
  5. process.arguments = ["-c", String(format:"%@", cmd)]
  6. process.standardOutput = pipe
  7. let fileHandle = pipe.fileHandleForReading
  8. process.launch()
  9. return String(data: fileHandle.readDataToEndOfFile(), encoding: .utf8)
  10. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement