I'm trying to run shell commands using Swift in my OSX app.
Running basic commands such as echo work fine 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 "sh: node: command not found" when running the system command.
system("node -v")
Update:
Not as nice as some of the suggestions below, but I managed to echo the command into a file and have it opened and executed in terminal:
system("echo node -v > ~/installation.command; chmod +x ~/installation.command; open ~/installation.command")
node? What happens when you trynode -vin Terminal?