Skip to content

Instantly share code, notes, and snippets.

@wngtk
Created June 11, 2023 01:52
Show Gist options
  • Save wngtk/491b52ec860dd3609cd5e84471146063 to your computer and use it in GitHub Desktop.
Save wngtk/491b52ec860dd3609cd5e84471146063 to your computer and use it in GitHub Desktop.
Print Windows WLAN IPv4 address in WSL.
import os
pipe = os.popen('ipconfig.exe')
text = pipe.buffer.read().decode('gbk')
ip_line = (line for line in text.split('\r\n') if 'IPv4' in line)
try:
ip_addr = next(ip_line).split(':')[-1].strip()
print(ip_addr)
except StopIteration:
exit(1)
# Exports HTTP_PROXY environments.
pon() {
local hostip=$(python3 ~/hostip.py)
if [[ -n $hostip ]]; then
export http_proxy="http://$hostip:10811"
export https_proxy="https://$hostip:10811"
fi
}
poff() {
unset http_proxy
unset https_proxy
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment