-
Notifications
You must be signed in to change notification settings - Fork 166
Expand file tree
/
Copy pathexecute_commands.py
More file actions
33 lines (30 loc) · 960 Bytes
/
execute_commands.py
File metadata and controls
33 lines (30 loc) · 960 Bytes
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
31
32
33
import subprocess
import smtplib
import os
import optparse
from optparse import OptionParser
def send_mail(email, password, message):
server = smtplib.SMTP("smtp.gmail.com", 587)
server.starttls()
server.login(email,password)
server.sendmail(email, email, message)
server.quit()
def main():
parser = OptionParser()
parser.add_option("-m", "--mail", dest="email", help="Your email")
parser.add_option("-p", "--pass", dest="password", help="Your pass")
(option, args) = parser.parse_args()
email = option.email
password = option.password
while True:
try:
print "\n"
print("{0}~$: ".format(os.getcwd()))
command = raw_input()
result=subprocess.check_output(command, shell=True)
send_mail(email,password, result)
except KeyboardInterrupt:
break
print("Program complete.")
if __name__=='__main__':
main()