PINE64
Calling an external command in Python - Printable Version

+- PINE64 (https://forum.pine64.org)
+-- Forum: PINE A64(+) (https://forum.pine64.org/forumdisplay.php?fid=4)
+--- Forum: Android on Pine A64(+) (https://forum.pine64.org/forumdisplay.php?fid=5)
+--- Thread: Calling an external command in Python (/showthread.php?tid=3198)



Calling an external command in Python - douglassirkshaun - 01-30-2017

How can I call an external command (as if I'd typed it at the Unix shell or Windows command prompt) from within a Python script?


RE: Calling an external command in Python - MarkHaysHarris777 - 01-30-2017

(01-30-2017, 09:31 AM)douglassirkshaun Wrote: How can I call an external command (as if I'd typed it at the Unix shell or Windows command prompt) from within a Python script?

The sys module and the os module will be helpful for you.

from sys import *
from os import *

or,  just import the components you need.

http://www.python-course.eu/sys_module.php

http://www.python-course.eu/os_module_shell.php

Read the two links posted above.  Specifically the os module will allow you to make shell commands from python scripts.  The sys module will help you get input args (argv) and to get information about the system into your python scripts.