Page 1 of 1

Executing external program on Linux

Posted: Sat Aug 08, 2015 10:08 am
by bmarkus
Hi,

how can I execute an external program/os shell from the Unix version?

Thanks... Béla

Re: Executing external program on Linux

Posted: Sat Aug 08, 2015 11:00 am
by pfalcon
Just the same as usual - e.g. os.system(), os.pipe(). There's no "subprocess" module currently.

Re: Executing external program on Linux

Posted: Sat Aug 08, 2015 11:42 am
by bmarkus
Thanks, os.system() and os.pipe() is suitable. On our TC (Tiny Core) Linux we have several applications written in shell (BusyBox ASH). In general it is OK, but there are few more complex cases where ASH programming is a pain. I think micropython can be a good choice to migrate shell scripts to Python, but need some work to port scripts and make an evaluation.

Re: Executing external program on Linux

Posted: Sat Aug 08, 2015 12:20 pm
by pfalcon
That's exactly the usecase for the unix version of MicroPython, I e.g. wanted to be able to write Python scripts/apps for OpenWRT which would work with just builtin flash, where CPython just won't fit. Feel free to share your experiences, report missing functionality to https://github.com/micropython/micropython-lib/issues , or even better, contribute missing parts ;-).

Re: Executing external program on Linux

Posted: Sat Aug 08, 2015 5:41 pm
by bmarkus
Good to see others are doing the same. Tested, os module works fine, so I have everything to start testing some code on the Raspberry Pi with piCore Linux.

Re: Executing external program on Linux

Posted: Wed Aug 19, 2015 6:27 am
by bmarkus
So far it looks good. I'm installing extensions during startup dynamically using a dictionary and lists. The only issue is the low default RAM size in UNIX build, 128k. I'm running out memory frequently even with moderate size and simple dicts. Running gc explicitely helps a bit.

I opened a ticket to increase default size.

https://github.com/micropython/micropython/issues/1433