Executing Terminal Commands in Python & PHP


Read {count} times since 2020

Python & PHP are great languages and there are many similarities between them. In this short post, you will learn how to execute terminal commands in PHP & Python.

PHP

As I said before many times in other posts, there areexec andsystem command to execute commands :

exec("firefox ‘http://subinsb.com’");

Or in the other way :

system("firefox ‘http://subinsb.com’");

Python

In Python, there is no exec or system function. But there is a system function in the os nodule. So, you have to include the os module first and then execute the command :

import os
os.system("firefox ‘http://subinsb.com’")
Show Comments