Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import Foundation
- func execCommand(command: String, args: [String]) -> String {
- if !command.hasPrefix("/") {
- let commandFull = execCommand(command: "/usr/bin/which", args: [command]).trimmingCharacters(in: CharacterSet.whitespacesAndNewlines)
- return execCommand(command: commandFull, args: args)
- } else {
- let proc = Process()
- proc.launchPath = command
- proc.arguments = args
- let pipe = Pipe()
- proc.standardOutput = pipe
- proc.launch()
- let data = pipe.fileHandleForReading.readDataToEndOfFile()
- return String(data: data, encoding: String.Encoding.utf8)!
- }
- }
- let commandOutput = execCommand(command:"file-roller", args:["Hello, I am here!"])
- print("Command output: (commandOutput)")
- /usr/lib/swift/CoreFoundation/CoreFoundation.h:25:10: note: while building module 'SwiftGlibc' imported from /usr/lib/swift/CoreFoundation/CoreFoundation.h:25:
- #include <sys/types.h>
- ^
- [
- {
- "id": "tools",
- "children":
- [{
- "caption": "SublimeREPL",
- "mnemonic": "r",
- "id": "SublimeREPL",
- "children":
- [
- {"command": "repl_open",
- "caption": "Swift",
- "id": "repl_swift",
- "args": {
- "type": "subprocess",
- "external_id": "swift",
- "encoding": "utf8",
- "cmd": {
- "osx": ["/Applications/Xcode6-Beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift"],
- "linux":["swift"]},
- "cwd": "$file_path",
- "additional_scopes": ["swift"],
- "syntax": "Packages/Swift/Syntaxes/Swift.tmLanguage"
- }
- }
- ]
- }]
- }
- ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement