-
Notifications
You must be signed in to change notification settings - Fork 0
/
ping.py
37 lines (31 loc) · 873 Bytes
/
ping.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
31
32
33
34
35
36
37
import ftplib
import sys
import os
import re
from datetime import datetime
new_f=ftplib.FTP("182.50.134.1")
new_f.login("myriadsdigital", "Password*123")
#print ('Files in home direcotory:---')
#new_f.retrlines('LIST')
#print('\n')
vlist=os.listdir('.')
name=''
for item in vlist:
match=re.search(r'system\w*', item)
if match:
name=match.group()[6:]
print name
f = open('locallog.txt','w')
time = datetime.now()
if os.system("ps -e|grep mplayer") == 0 :
f.write('System no '+name+' working at '+ datetime.isoformat(time))
else:
f.write('System no '+name+' not working at '+ datetime.isoformat(time))
f.close()
f = open("locallog.txt", "rb")
new_f.cwd("/log")
new_f.storlines("APPE log.txt", f)
new_f.retrlines('LIST')
print ('Log uploaded sucessfully!\n')
new_f.quit()
f.close()