How to call an external command from Python

0 votes

Hi Guys,

I have created one python script. I want to use one Linux command inside this python script. How can I do this?

Jun 24, 2020 in Python by akhtar
• 38,210 points
135 views

1 answer to this question.

0 votes

Hi@akhtar,

You can use the os module in python. It helps you to run the Linux command in your python script. Use the below-given code in your script.

import os
os.system("ls -l")

I hope you will get some idea.

answered Jun 25, 2020 by MD
• 95,300 points

Related Questions In Python

0 votes
1 answer

How to call Python script from bash with an agrument?

Hi, You need to call the same command ...READ MORE

answered Jun 25, 2019 in Python by Shabnam
• 930 points
9,035 views
0 votes
1 answer

How to call an external command?

Hello @kartik, Look at the subprocess module in the standard ...READ MORE

answered Nov 18, 2020 in Python by Niroj
• 82,820 points
62 views
0 votes
1 answer

How to call an external command?

Look at the subprocess module in the standard library: import ...READ MORE

answered Nov 19, 2020 in Python by Gitika
• 65,950 points
94 views
0 votes
1 answer

I'm using Python 2.7 to convert an XML response (from a REST call to Atlassian Fisheye) into an HTML table.

You don't have a template matching tabularQueryResult in your ...READ MORE

answered Oct 4, 2018 in Python by Priyaj
• 58,140 points
326 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 2,423 views
0 votes
0 answers
+5 votes
6 answers

Lowercase in Python

You can simply the built-in function in ...READ MORE

answered Apr 11, 2018 in Python by hemant
• 5,810 points
1,823 views
0 votes
1 answer

How to call a function from another file in Python?

Hi@akhtar, You can use the import keyword to ...READ MORE

answered Jun 24, 2020 in Python by MD
• 95,300 points
2,659 views
0 votes
1 answer

How to crop face from a photo using cv2 in python?

Hi@akhtar, You can do this task using cv2 ...READ MORE

answered Apr 9, 2020 in Python by MD
• 95,300 points
209 views