Knowledge Base
MilesWeb / Web Hosting FAQ

{Introduction} – Python script basics

Approx. read time : 3 min

The article provides important information about using Python on MilesWeb hosting servers.

# Permissions required to set the Python script files

Choosing the correct permissions for Python script files depends on the script’s particular function :

To use Python CGI script files that can be publicly accessible through the web, you need to set the file permissions to 755 (i.e. read, write and execute permissions for the user. Also read and execute permissions for the group and world). You don’t have to provide the world write permission to the Python script.

To use Python script files that you only run on the command line, you need to set the file permission to 700 (i.e. read, write and execute permissions for the user and there is no need of any permission for the group and world.)

# File extensions that can be used for Python script files

Python script files have a .py or .cgi extension. However, with the file permissions, the file extension that you use generally, depends on the script’s function:

The Python script files that generate the web output accessible to the public use the .cgi extension.
The Python script files that you run only through the command line, and script files which do not generate web output, should use the .py extension.

# Find out the Python version installed on MilesWeb hosting server

To determine which Python version is set as default on the server, type the following command :

# Find a path to the Python executable

The absolute path to the default Python executable on MilesWeb hosting servers is /usr/bin/python. Generally, you don’t have to include the full path when you run Python scripts from the command line, because the /usr/bin directory is set in the default path. To do this, type the following command :

# To run different Python versions

There are many different versions of Python available. You can view the Python version available on your server by the following command :

For example, if you want to run a script using Python version 3, then type the following command.

Replace filename with your script file name.

Also Read :

1) {Introduction} – Perl Script Basics

With an interest in doing something creative daily, Sonam works as a Digital Marketing Executive. She likes to write technical blogs related to web hosting, digital marketing, and other IT topics. She also likes to spend her leisure time on social media to find different strategies for client engagement.
Need help? We’re always here for you.