Re: Unable to get the gateway IP of wlan interface using python code

2018-11-13 Thread srinivasan
As am a beginner with the python Syntax, I was able to parse the gateway IP as below, Please do let me know if anyone forsee any issues in the below?: def get_gateway_ip(self): """ Get the Gateway IP address of the AP. :return: Gateway IP. """

Re: Unable to get the gateway IP of wlan interface using python code

2018-11-13 Thread srinivasan
Hi Wildman, The below snippet seems to be fine, how can I specify to get the specific wlan0 interface gateway IP in the below code snippet? # #!/usr/bin/env python import socket import struct def get_gateway_ip(): try: with open("/proc/net/route", "r") as f:

Re: [Tutor] Unable to get the gateway IP of wlan interface using python code

2018-11-12 Thread Michael Torrie
On 11/12/2018 05:55 PM, David Rock wrote: > Is there a requirement to use only what comes in the standard libraries, or > can you use things from pypi? > Getting interface details is exactly why netifaces was created > > https://pypi.org/project/netifaces/ Also if working with NetworkManager is

Re: Unable to get the gateway IP of wlan interface using python code

2018-11-12 Thread Wildman via Python-list
I tried posting this already but it didn't make it. I am trying again... On Tue, 13 Nov 2018 01:07:06 +0530, srinivasan wrote: > Dear Python Experts, > > *First method:* > > I need to get the IP address basically the gateway IP I am assuming your platform is Linux. If I am incorrect then

Re: [Tutor] Unable to get the gateway IP of wlan interface using python code

2018-11-12 Thread Bill Campbell
On Tue, Nov 13, 2018, srinivasan wrote: >Dear Python Experts, > >*First method:* > >I need to get the IP address basically the gateway IP in my setup I get it >as "192.168.178.1" when I run the below standalone python code. > > >*def get_gateway_ip(self):* >*"""* >*Get the

Re: [Tutor] Unable to get the gateway IP of wlan interface using python code

2018-11-12 Thread David Rock
> On Nov 12, 2018, at 13:37, srinivasan wrote: > > Dear Python Experts, > > *First method:* > > I need to get the IP address basically the gateway IP in my setup I get it > as "192.168.178.1" when I run the below standalone python code. Is there a requirement to use only what comes in the

Re: Unable to get the gateway IP of wlan interface using python code

2018-11-12 Thread Cameron Simpson
On 12Nov2018 21:17, MRAB wrote: On 2018-11-12 19:37, srinivasan wrote: When I use the subprocess I see the below issue: def get_gateway_ip(self): [...] p = subprocess.Popen('ip route show 0.0.0.0/0 dev wlp1s0 | cut -d\ -f3', stdout=subprocess.PIPE) [...]

Re: Unable to get the gateway IP of wlan interface using python code

2018-11-12 Thread MRAB
On 2018-11-12 19:37, srinivasan wrote: Dear Python Experts, [snip] *SECOND METHOD:* When I use the subprocess I see the below issue: def get_gateway_ip(self): """ Get the IP address to the WIFI module from the AP """ #cmd = 'ip route show

Unable to get the gateway IP of wlan interface using python code

2018-11-12 Thread srinivasan
Dear Python Experts, *First method:* I need to get the IP address basically the gateway IP in my setup I get it as "192.168.178.1" when I run the below standalone python code. *def get_gateway_ip(self):* *"""* *Get the IP address to the WIFI module from the AP* *