Python Forum

Full Version: Help to activate the "USB Modem" with Python
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi everyone,

I am trying to activate and deactivate the "usb modem" by Python code, but it does not work, do you know any way to do it?

USB Modem:

[Image: vodafonethestickusb.jpg]

I tried with "cmd" command line but it did not work Cry :
import os
cmd = 'ifconfig wlan0 down'
os.system(cmd)

I appreciate very your comments

Regards
Karlo
I don't see where this is related to python.
Quote:I tried with "cmd" command line but it did not work
show complete script,
how you ran it from cmd line and
full verbatim traceback
Hi,

I do it for wifi and it works, but it does not work for the usb modem:

-------------------------------
import os, sys
import time

os.system("Ipconfig /release")

time.sleep(3)

os.system("Ipconfig /renew")

------------------------------
Do you know any other way?

Thanks for the feedback
I presume you are using Windows and that the device is configured correctly and works without Python.

The commands are ipconfig /renew <Adapter> and ipconfig /release <Adapter> .

The Adapter option is only available for a device using DHCP. For devices using a static ip address you need to specify the adapter name, which can be found using ipconfig /all . Refer to MS Technet ipconfig.