Category: Python3

Added: 1st of December 2020

Viewed: 365 times

Learning Python3, System calls on Linux

The tutorial presumes you already have Python3 installed on your system. If you don't please visit my other tutorial, How to create a basic Python3 script in Ubuntu and Ubuntu based distributions

To make a system call from your Python script, for example displaying the current version of Python3 using the command python3 --version, we need to use the import os module, and use the os.system function

Create a new file named system_call.py and copy and paste the code below

#!/usr/bin/python3

import os
os.system('python3 --version')


Then enter the following command to make the Python script executable
chmod +x system_call.py


Then run the script by the entering the command
./system_call.py


If everything works correctly the current version of Python3 will be display in the terminal

Other Tips & Tutorials

Python3

Learning Python 3, check user input is an integer

Posted: 11th of December 2020

Views: 402

Python3

Learning Python3, Generate a random number using Python3

Posted: 8th of December 2020

Views: 343

Python3

Learning Python 3, getting basic user input and printing the results

Posted: 7th of December 2020

Views: 379

Python3

Learning Python3, System calls on Linux

Posted: 1st of December 2020

Views: 365

Python3

Create a new window using GTK and Python in Ubuntu and Ubuntu based distributions

Posted: 19th of November 2020

Views: 329

Python3

How to create a basic Python3 script in Ubuntu and Ubuntu based distributions

Posted: 28th of April 2020

Views: 769