Advertisement
Guest User

Untitled

a guest
Aug 19th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 KB | None | 0 0
  1. import Foundation
  2.  
  3. func execCommand(command: String, args: [String]) -> String {
  4. if !command.hasPrefix("/") {
  5. let commandFull = execCommand(command: "/usr/bin/which", args: [command]).trimmingCharacters(in: CharacterSet.whitespacesAndNewlines)
  6. return execCommand(command: commandFull, args: args)
  7. } else {
  8. let proc = Process()
  9. proc.launchPath = command
  10. proc.arguments = args
  11. let pipe = Pipe()
  12. proc.standardOutput = pipe
  13. proc.launch()
  14. let data = pipe.fileHandleForReading.readDataToEndOfFile()
  15. return String(data: data, encoding: String.Encoding.utf8)!
  16. }
  17. }
  18.  
  19. let commandOutput = execCommand(command:"file-roller", args:["Hello, I am here!"])
  20. print("Command output: (commandOutput)")
  21.  
  22. /usr/lib/swift/CoreFoundation/CoreFoundation.h:25:10: note: while building module 'SwiftGlibc' imported from /usr/lib/swift/CoreFoundation/CoreFoundation.h:25:
  23. #include <sys/types.h>
  24. ^
  25.  
  26. [
  27. {
  28. "id": "tools",
  29. "children":
  30. [{
  31. "caption": "SublimeREPL",
  32. "mnemonic": "r",
  33. "id": "SublimeREPL",
  34. "children":
  35. [
  36. {"command": "repl_open",
  37. "caption": "Swift",
  38. "id": "repl_swift",
  39. "args": {
  40. "type": "subprocess",
  41. "external_id": "swift",
  42. "encoding": "utf8",
  43. "cmd": {
  44. "osx": ["/Applications/Xcode6-Beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift"],
  45. "linux":["swift"]},
  46. "cwd": "$file_path",
  47. "additional_scopes": ["swift"],
  48. "syntax": "Packages/Swift/Syntaxes/Swift.tmLanguage"
  49. }
  50. }
  51. ]
  52. }]
  53. }
  54. ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement