Created
June 11, 2023 01:52
-
-
Save wngtk/491b52ec860dd3609cd5e84471146063 to your computer and use it in GitHub Desktop.
Print Windows WLAN IPv4 address in WSL.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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