I am trying to run shell commands using Swift in my OSX application.
The execution of basic commands, such as echo-work, stops, but the following throws
"env: node: no such file or directory"
@IBAction func streamTorrent(sender: AnyObject) {
shell("node", "-v")
}
func shell(args: String...) -> Int32 {
let task = NSTask()
task.launchPath = "/usr/bin/env"
task.arguments = args
task.launch()
task.waitUntilExit()
return task.terminationStatus
}
I also get the command "sh: node: command not found" when I run the system command.
system("node -v")
Update:
Not as good as some of the suggestions below, but I managed to execute the echo command in the file and open it and execute in the terminal:
system("echo node -v > ~/installation.command; chmod +x ~/installation.command; open ~/installation.command")
source
share