motionEyeOS (PINE A64(+)) 20170611 [Jun 16] | Ubuntu Images (Pinebook) 0.5.5-65 [Jun 15] | Ubuntu Minimal (PINE A64(+)) 0.5.5-65 [Jun 15] | Q4OS (Pinebook) 1805 [Jun 12] | Android 6.0.1 (Pinebook) 20170605 [Jun 5] | Win10 IoT (PINE A64(+)) 10.0.15063.0_20170602 [Jun 5] | FalconGate (PINE A64(+)) 20170430 [May 31] | Q4OS (PINE A64(+)) 1804 [May 30] | Armbian - Ubuntu (SOPINE) 5.27 [May 22]

Getting Started | Visit the WIKI | IRC Logs | Forum Rules/Policy


Calling an external command in Python
#1
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?
Reply
#2
(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.
marcushh777    Cool

please join us for a chat @  irc.pine64.xyz:6667   or ssl  irc.pine64.xyz:6697

( I regret that I am not able to respond to personal messages;  let's meet on irc! )
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)