Run Unix command within Python

0 votes
I want to run a unix command from within my python script for my app. How do I do that?
Apr 27, 2018 in Python by wannabelinuxgeek
11 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

From the python docs, use the subprocess module -

>>> subprocess.call(["ls", "-l"])
0

answered Apr 27, 2018 by Nietzsche's daemon
• 4,260 points

Related Questions In Python

0 votes
1 answer

Call a shell command in Python?

Try this - os.system("commands and arguments") READ MORE

answered Jun 21, 2018 in Python by Hamartia's Mask
• 1,580 points
16 views
0 votes
2 answers

How to run the Python program forever?

No, you can use while: pass I ...READ MORE

answered 1 day ago in Python by Lehan
316 views
0 votes
1 answer

'python' is not recognized as an internal or external command

I have met same issue when I ...READ MORE

answered Aug 24, 2018 in Python by Priyaj
• 56,120 points
60 views
0 votes
1 answer

Make a unix alias with python script

The scope of an alias command is the shell ...READ MORE

answered Sep 10, 2018 in Python by Priyaj
• 56,120 points
11 views
0 votes
1 answer

how can i count the items in a list?

suppose you have a list a = [0,1,2,3,4,5,6,7,8,9,10] now ...READ MORE

answered May 2 in Python by Mohammad
• 1,400 points
19 views
+4 votes
6 answers
0 votes
1 answer

Reading Unix Timestamp in Python

import datetime print(datetime.datetime.fromtimestamp(int("1284101485")).strftime('%Y-%m-%d %H:%M:%S')) That is the cleanest way ...READ MORE

answered May 15, 2018 in Python by Nietzsche's daemon
• 4,260 points
58 views
+4 votes
6 answers

Does Python have a ternary conditional operator like C does?

Yes, the syntax is: a if condition else ...READ MORE

answered Apr 13, 2018 in Python by Nietzsche's daemon
• 4,260 points
67 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.