0

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.

Community
  • 1
  • 1
arsenalist
  • 167
  • 4
  • 13
  • For stopping wvdial from python, we might use `sudo poff.wvdial setting1` – arsenalist Dec 12 '14 at 17:28
  • the answer that you've referenced is incorrect -- setting `stdout=PIPE` has nothing to do with "backgroundness". The proper way to start/stop `wvdial` service is to use whatever your distribution uses to start/stop daemons e.g., on my system it is `start/stop` commands (symlinks to `initctl` command). – jfs Dec 16 '14 at 17:03

0 Answers0