Reputation: 112
I have created this python script called 'SleepCalc.py'. It is a simple script that tells me when to wake up based on 90 minute sleep cycles. Usually I open terminal, cd command my way to the dir containing the .py and then execute the script with the 'python' command.
What I want to know is how can I make an app/automator workflow/apple script that I can double click and it executes the python script in the terminal without me having to cd, etc.
http://codebin.org/view/98c0b7c5
Upvotes: 0
Views: 1086
Reputation: 548
You open Terminal and enter nano
at the top. It opens up a Terminal-based text editor.
After that, type python
followed by the file path (at the beginning, include ~/
because the computer starts at the root).
Do Control-X
, click Yes
, and save it as launch.command
.
After that, type chmod +x
and drag the newly created file into the Terminal window. This gives permission for the file to execute.
From then on, you can double click the .command
file to launch SleepCalc.py
.
Upvotes: 0
Reputation: 3066
Add shebang: #!/usr/bin/env python
at the top of your script.
And then give the file permission to execute by:
chmod +x SleepCalc.py
Upvotes: 4