在Swift里执行Shell命令


let task = NSTask()
task.launchPath = "/bin/echo"
task.arguments = ["-c".Command]
 
let pipe = NSPipe()
task.standardOutput = pipe
task.launch()
 
let data = pipe.fileHandleForReading.readDataToEndOfFile()
let output: String = NSString(data: data, encoding: NSUTF8StringEncoding)
 
print(output)
已标记关键词 清除标记
相关推荐
©️2020 CSDN 皮肤主题: 创作都市 设计师:CSDN官方博客 返回首页