Avatar
omochimetaru 4/5/2018 9:16 PM
@swiftbot import Foundation func exec(_ cmd: [String]) -> String { let process = Process() process.launchPath = cmd[0] let pipe = Pipe() process.standardOutput = pipe process.arguments = Array(cmd[1...]) process.launch() let handle = pipe.fileHandleForReading let data = handle.readDataToEndOfFile() process.waitUntilExit() let str = String(data: data, encoding: .utf8) ?? "<binary>" return str } print(exec(["/bin/cat", ".dockerenv"]))