Saturday, April 23, 2022

[SOLVED] Execute Commands in Kali-Linux's Terminal through Python

Issue

I want to execute commands in the terminal through a python scripts.

i want to create a script which takes data from a .txt file adds that in a list and then one by one execute them in the terminal.

what i am looking for is a process to execute commands in the terminal in Kali Linux, I couldn't find anything online.

like in windows we use import subprocess or import os

Thank you.

example command is like

python3 app.py

Solution

Try this:

import subprocess
command = "python3 app.py"
subprocess.call(command, shell=True)


Answered By - lokesh
Answer Checked By - David Marino (WPSolving Volunteer)