Calling an OS system command

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
mozartatplay
Posts: 1
Joined: Sat Jul 28, 2018 2:39 pm

Calling an OS system command

Post by mozartatplay » Sat Jul 28, 2018 3:11 pm

Is there there a way in micropython do do something similar to os.popen or subprocess.popen. I need to call a system command and push it through sed and awk and pull the result back into micropython

Thanks

ThomasChr
Posts: 3
Joined: Sat Nov 25, 2017 7:50 am

Re: Calling an OS system command

Post by ThomasChr » Sun Jul 29, 2018 8:57 pm

On Micropython there is no OS. What do you expect?

stijn
Posts: 257
Joined: Thu Apr 24, 2014 9:13 am

Re: Calling an OS system command

Post by stijn » Mon Jul 30, 2018 7:15 am

ThomasChr wrote:
Sun Jul 29, 2018 8:57 pm
On Micropython there is no OS.
That depends on the port, the non-microcontroller ones do run on top of an OS. Since the OP asks about sed/awk/... this is likely the unix port.

Calling system commands (e.g. subprocess module) isn't currently implemented. You could achieve this using ffi calls though.

SpotlightKid
Posts: 334
Joined: Wed Apr 08, 2015 5:19 am

Re: Calling an OS system command

Post by SpotlightKid » Mon Jul 30, 2018 8:06 am

os.system() and os.fork() are implemented in micropython-lib for the unix port. See some simple examples here: https://github.com/micropython/micropyt ... /master/os

stijn
Posts: 257
Joined: Thu Apr 24, 2014 9:13 am

Re: Calling an OS system command

Post by stijn » Mon Jul 30, 2018 8:39 am

ah, good find, I was looking at the subprocess module only but that's just a stub

Post Reply