Executing Terminal Commands in Python & PHP

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.


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’”);


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’”)