-
Notifications
You must be signed in to change notification settings - Fork 0
/
mostrarIp1.py
30 lines (29 loc) · 1.16 KB
/
mostrarIp1.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# =============================================================================
# Created By : DevelopmentMen
# Created Date: vie Jun 10 16:20:00 2021
# =============================================================================
"""este simple script muestra la ip para windows y linux"""
# =============================================================================
# Imports
# =============================================================================
import socket as s
from subprocess import check_output
# =============================================================================
def forWindows():
try:
print("Windows ===================")
print("==> IP Address is: {}\n".format(s.gethostbyname(s.gethostname())))
except Exception:
pass
def forLinux():
try:
ips = check_output(['hostname', '--all-ip-addresses'])
print("Linux =====================")
print("==> IP Address is: {}\n".format(ips.decode()))
except Exception:
pass
if __name__ == "__main__":
forWindows()
forLinux()