Knowledge Base Hub

Browse through our helpful how-to guides to get the fastest solutions to your technical issues.

Home  >  Web Hosting FAQ  >  {Introduction} – Python script basics
Top Scroll

{Introduction} – Python script basics

 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 :

python -V

# 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 :

python filename

# 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 :

ls /usr/bin/python*

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

python3 filename

Replace filename with your script file name.

Also Read :

1) {Introduction} – Perl Script Basics

For our Knowledge Base visitors only
Get 10% OFF on Hosting
Special Offer!
30
MINS
59
SECS
Claim the discount before it’s too late. Use the coupon code:
STORYSAVER
Note: Copy the coupon code and apply it on checkout.