Good morning,
in my OSx App I would like to execute a command from the shell. As long as I did it with apple script or in the Terminal window it worked fine. but when I execute it via swift it won't work. the command is:
ssh -p 10001 root@nozbfa.anywareip.net -L 23389:192.168.38.11:3389 -f sleep 20
I tried it via a function
@discardableResult
func shell(_ args: String...) -> String {
let task = Process()
task.launchPath = "/bin/bash/"
task.arguments = args
let pipe = Pipe()
task.standardOutput = pipe
task.launch()
task.waitUntilExit()
let data = pipe.fileHandleForReading.readDataToEndOfFile()
guard let output: String = String(data: data, encoding: .utf8) else { return "" } return output
}
shell("ssh", script)
var script is:
-p 10001 root@nozbfa.anywareip.net -L 23389:192.168.38.11:3389 -f sleep 20
and it returns:
/usr/bin/ssh: /usr/bin/ssh: cannot execute binary file
what am I doing wrong?