ios - Swift 3 and Shell command with non regular arguments -
when calling through terminal
(echo authenticate '""'; echo signal newnym; echo quit) | /usr/bin/nc localhost 9051
it works fine. need use via swift. how write put in arguments?
p.s. searching lot of shell syntax , using shell in swift/objc... still can nothing that...
that's shell function:
func shell(_ path: string = "/bin/bash", arguments: [string] = [], waituntilexit: bool = false) -> string { let task = process() task.launchpath = path task.arguments = arguments let pipe = pipe() task.standardoutput = pipe task.launch() let data = pipe.filehandleforreading.readdatatoendoffile() if waituntilexit { task.waituntilexit() } return string(data: data, encoding: string.encoding.utf8)! }
calling
self.shell(arguments: ["(echo authenticate '""'; echo signal newnym; echo quit) | /usr/bin/nc localhost 9051"])
output is
no such file or directory (echo authenticate '""'; echo signal newnym; echo quit)
swift thinks (
directory. why?
Comments
Post a Comment