MacOS – How to associate the script file with the terminal on Mac OSX so that the icon starts terminal?

I have a python script, I can use the terminal to run in the usual way. For example, start Terminal, cd to the directory, and then type ./xxx.py, where xxx.py contains The name of the file of the script.

Now I want to create an icon to start the terminal on the desktop and run the python file when I double-click it. How do I do it? I thought I could use the cd and launch commands to create a shell file, and then associate the shell file with Terminal. But I can’t seem to associate it with the terminal.

Someone said to use the suffix “.command” Name the shell file, but this causes it to launch Flash Builder. I don’t know where the employee is. I can’t manually associate the terminal because I can’t find it. It’s not in /Applications.

On the desktop, you can create a file with the following content

# !/bin/bash

python PATH_TO_YOUR_PYTHON_FILE

Then you have to make it executable

chmod u+x FILE_ON_DESKTOP

pre>

Alternatively, you can create a symbolic link to the python file and make it executable.

You can find the terminal in /Applications/Utilities

I have a python script that I can use the terminal to run in the usual way. For example, start Terminal, cd to the directory, and type ./xxx.py, where xxx.py is the name of the file containing the script. < p>

Now I want to create a terminal icon on the desktop and run the python file when I double-click it. How can I do it? I thought I could use the cd and launch commands to create a shell file, and then associate the shell file with Terminal. But I can’t seem to associate it with the terminal.

Someone said to use the suffix “.command” Name the shell file, but this causes it to launch Flash Builder. I don’t know where the employee is. I can’t manually associate the terminal because I can’t find it. It’s not in /Applications.

On the desktop, you can create a file with the following content

#!/bin/bash

python PATH_TO_YOUR_PYTHON_FILE

Then you have to make it executable

chmod u+x FILE_ON_DESKTOP

Or, you can create a pointer to python Symbolic link to the file and make it executable.

You can find the terminal in /Applications/Utilities

Leave a Comment

Your email address will not be published.