1

I'm new to swift and I'm trying to run a Python file from it.

I already got the full path to the file, and my tries with NStask failed so far.

Now I'm somehow stuck launching the python executable with the path to the script as a parameter :-/ I already thought of just creating an .sh file with the appropriate command in it (python $filename) and launch that, but isn't there another way?

Of course I'm running OS X 10.10

Thanks for any help!

1 Answer 1

3

This should work:

system("python EXECUTABLE_PATH")

Josh

Sign up to request clarification or add additional context in comments.

4 Comments

Thank you Josh - Alright... so no NStask at all or how does that "system" work? --- Will try it tomorrow when I'm back at work ;-)
system() is a BSD library function, so you'll be able to get the documentation through man system. This link (showing how to get the output) might be useful to you: practicalswift.com/2014/06/25/…
is there a way to show the window of the terminal which got opened? Right now it's just writing in the console (which I can't see when I'd compile the app)
You can, but you'd have to use NSAppleScript. You're probably better off writing your own interface. P.S. next time you might want to be more specific with your question.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.