First attempt
This commit is contained in:
parent
13f9a0483b
commit
ed52755abe
26
main.py
Executable file
26
main.py
Executable file
@ -0,0 +1,26 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
import os
|
||||
import sys
|
||||
from wakeonlan import send_magic_packet
|
||||
|
||||
def check_status(ip):
|
||||
res = os.system("ping -n -c 1 " + ip + " > /dev/null")
|
||||
if res == 0:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
def main():
|
||||
ip = "127.0.0.1"
|
||||
mac = "ff-ff-ff-ff-ff-ff"
|
||||
if check_status(ip):
|
||||
print("System is up")
|
||||
sys.exit(0)
|
||||
else:
|
||||
print("System is down")
|
||||
print("Sending WoL magic packet to " + mac)
|
||||
send_magic_packet(mac)
|
||||
sys.exit(1)
|
||||
main()
|
||||
|
Loading…
Reference in New Issue
Block a user