I have several USB modem attached to my RPi. I want to send SMS, make a call, and connect to internet with each one of them in sequence.
As for modem connection to internet, I use WvDial
. I was able to connect to internet and do things, like ping and measure upload and download speed with multiple modems by connecting to one of them at one time. Or in short, I start and stop WvDial
that correspond to each modem.
Now, I want to start and stop WvDial from my python
program. I've used python subprocess
, but after the WvDial execution, my next code wouldn't be executed.
print "WvDial from subprocess python"
try:
processDial = subprocess.Popen(
['sudo wvdial setting1'],
shell = True
)
processDial.communicate()
print "after WvDial" #this part was not executed
Also note, that I cannot have all WvDial process to run at all time, because I need the modem to send SMS and makes call.
So, how to start and stop WvDial process from python code?
Thanks for your time and cooperation
Edit: after searching again today, I stumbled upon to this answer https://stackoverflow.com/a/7224186/1947536 which answer my question. In short, subprocess.Popen
only runs the process in the background if nothing in the python script depends on the output of the command being run.