Code Monkey home page Code Monkey logo

wake-on-lan-python's Introduction

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. 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 configuration file.

For a quick and lazy way to create the configuration file, see The Wake On Lan section of my router build documentation, or run the command without arguments to create a default config file in ~/.config/bentasker.Wake-On-Lan-Python/wol_config.ini

This is based on a recipe from http://code.activestate.com/recipes/358449-wake-on-lan/ which was then ameded to use a config file and hostnames.

Usage

wol.py [-p] [hostname|list]

-p            Prompt for input before exiting
list          List configured hosts
[hostname]    hostname to wake (as listed in list)

or

wol.py list

Usage: Docker

It is also possible to run the utility with Docker, however there is a small additional configuration step required the first time that it's run

Run list:

docker run \
--rm \
-v ~/.config/bentasker.Wake-On-Lan-Python/:/wol_config \
bentasker12/wake-on-lan-python list

Edit the generated configuration file

vi ~/.config/bentasker.Wake-On-Lan-Python/wol_config.ini

You will find that the broadcast address is for the wrong network, replace this with the correct prefix

[General]
broadcast = 172.0.1.255

becomes

[General]
broadcast = 192.168.1.255

Subsequent runs should then run as desired

docker run \
--rm \
-v ~/.config/bentasker.Wake-On-Lan-Python/:/wol_config \
bentasker12/wake-on-lan-python myPC

Configuration File

The configuration file is just a basic INI file, containing one section per host;

By default, the configuration file is located at ~/.config/bentasker.Wake-On-Lan-Python/wol_config.ini

The location can be overridden via environment variable WOL_CONFIG_DIR:

export WOL_CONFIG_DIR="/some/path/wol_config

If it does not exist, it will be created and wol_config.ini created within it.

The following is an example of hosts save in wol_config.ini

[General]
broadcast=192.168.1.255

[MyPc]
mac=00:13:0d:e4:60:61

License

Copyright (c) Fadly Tabrani, B Tasker, released under PSF v2, see LICENSE

wake-on-lan-python's People

Contributors

anonymousx86 avatar bentasker avatar dependabot[bot] avatar jnullj avatar jorturfer avatar lex-drl avatar rdch106 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

wake-on-lan-python's Issues

invalid hostname specified

Hi there,

I'm struggeling with getting "invalid hostname...."-error messages running the script.
Even if I try the wol.py list cmd it does not return anything.

Any suggestions on that ?

cheers
Ben

Try statement failed

Hello, sorry for my language, English is my bad.

So when, I try to use your script. I Have usage fonction calling every time ???
I think what the Try statement not run normaly.

My config INI have just one mac address.

Not reading wol_config.ini file.

Hi guys- cute script- thanks!
Just pointing out that in your code in line 66 you're referencing Config.read(mydir+"/.wol_config.ini") but wol_config.ini should not be a hidden file.

Cheers

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.