How do you run python script with arguments programmatically using swift

I am working on a MacOS project to turn my iOT device on and off. There is only a working python script to do it. I want to run these scripts from my MacOS project which I am writing in Swift

3 comments · 84% upvoted · other discussions

comments

[deleted]

Lookup the documentation for NSTask. I’m sure it does exactly what you need.

Bamboo_the_plant

Adding to that, here’s the Ray Wenderlich tutorial on it: https://www.raywenderlich.com/1197-nstask-tutorial-for-os-x

nithinreddygaddam [OP]

Thanks guys I was able to achieve it using NSTask