AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |
Back to Blog
Python wakeonlan10/5/2023 ![]() Output = subprocess.Popen(,stdout = subprocess.PIPE).communicate() New Code seems to be working, only issue is that it's ignoring time.sleep and just repeating once the ping finishes import os I don't know if it's even running my code tbh. Update: I changed the if conditional to != with the 10.0.0.5 host on to test if it's sending the packet, and it's not (confirmed with wireshark). S = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) Response = os.system("ping -c 1 " + hostname) The packet is constructed from the mac address given as a parameter. A magic packet is a packet that can be used with the for wake on lan protocol to wake up a computer. The code compiles but doesn't seem to be working. Small module for use with the wake on lan protocol. if it is down, send a wake on lan packet to the host, then test again in 10 seconds. I'm trying to write a script that checks if a host on my intranet is up. If response = 0 : pingstatus = "Awake" else : pingstatus = "Sleeping" return pingstatus def kick (): s = socket. system ( "ping -c 1 " + hostname ) # and then check the response. reply_token, replies ) def confirm (): hostname = "192.168.1.**" response = os. search ( message ): if confirm () = 'Awake' : replies += else : result = kick () replies += buttons_template = ButtonsTemplate ( title = 'usage', text = 'Tap below buttons', actions = ) template_message = TemplateSendMessage ( alt_text = 'Usage', template = buttons_template ) replies += line_bot_api. search ( message ): result = confirm () replies += elif re. To wake up a computer using wake on lan it must first be enabled in the BIOS settings. add ( MessageEvent, message = TextMessage ) def handle_message ( event ): message = event. Rather than needing to know the MAC address of the desired machine, the script allows you to specify by hostname, so long as that host is included in the. close () return 'kicked' if _name_ = '_main_' : app. Wake-On-Lan-Python wol.py is A small Python 3 script to allow the sending of a WOL Magic packet so that LAN clients can be remotely switched on from another machine on the same subnet. search ( message ): result = confirm () replies += elif re. handle ( body, signature ) except InvalidSignatureError : abort ( 400 ) return 'ok' handler. info ( "Request body: " + body ) # handle webhook body headers # get request body as textīody = request. route ( '/wake-on-lan', methods = ) def wake_on_lan (): # get X-Line-Signature header value ![]() ![]() route ( '/' ) def show_web (): return 'This is vpn server for wake on lan! \n\n ' app. I exposed port 9/udp and bound it port 9 of the host system. It works fine without the use of docker (normal uwsgi app directly on the server), but with docker it won't work. The app sends a wake on lan broadcast packet to wake a pc in the local network. exit ( 1 ) line_bot_api = LineBotApi ( channel_access_token ) handler = WebhookHandler ( channel_secret ) app. 13 I have a docker container running a python uwsgi app. exit ( 1 ) if channel_access_token is None : print ( 'Specify LINE_CHANNEL_ACCESS_TOKEN as environment variable.' ) sys. getenv ( 'LINE_CHANNEL_ACCESS_TOKEN', None ) if channel_secret is None : print ( 'Specify LINE_CHANNEL_SECRET as environment variable.' ) sys. getenv ( 'LINE_CHANNEL_SECRET', None ) channel_access_token = os. Import os, sys from flask import Flask, request, abort app = Flask ( _name_ ) from linebot import ( LineBotApi, WebhookHandler ) from linebot.exceptions import ( InvalidSignatureError ) from linebot.models import ( TextMessage, TextSendMessage, MessageEvent ) # get channel_secret and channel_access_token from your environment variableĬhannel_secret = os.
0 Comments
Read More
Leave a Reply. |