Yet another wake-on-lan command line script.
I couldn't find one that worked and did what I need. Specifically I need:
- A command line utility that works on Mac, Windows and Linux
- Can use saved configurations rather than force me to remember the MAC addresses of the machines I need to wake.
- Ideally, let me manipulate (create, delete, update, list) saved configurations using the same utility.
- Ideally, be open source so I can see what it is doing and know it doesn't do anything nefarious
None of the existing tools I found satisfied these criteria (even without the last two) so I wrote my own.
Pre-requisites: Python 3.7 or above. No additional packages required.
pip3 install eg.wakeonlan
On Windows, if you get a warning like:
WARNING: The script wakeonlan.exe is installed in
'C:\Users\[username]\AppData\Roaming\Python\Python[VER]\Scripts' which is not on PATH.
You can either add this directory to your PATH or run pip3 install
from Administrator command prompt.
The reason for this message is that Python does not add per user scripts directory to PATH on Windows, only the system-wide one. See this Python bug
wakeonlan XX:XX:XX:XX:XX:XX [-a BroadcastAddress] [-p Port]
If not specified BroadcastAddress is 255.255.255.255 and Port is 9
wakeonlan --save Name XX:XX:XX:XX:XX:XX [-a BroadcastAddress] [-p Port]
Name can be anything. The configuration is saved into $HOME/.wakeonlan
file in JSON format
--save can be abbreviated as -s
wakeonlan Name
wakeonlan --list
--list
can be abbreviated as -l
wakeonlan --delete Name
--delete
can be abbreviated as -d
Saved configurations are stored in $HOME/.wakeonlan
file (%USERPROFILE%\.wakeonlan
for Windows users).
Copy this file to another machine into equivalent location to transfer all the configurations.
Autocomplete is supported for bash
, zsh
and powershell
.
Add the following to your ~/.bashrc
source `wakeonlan --autocomplete-source`
Add the following to your ~/.zhrc
(make sure it is after the call to compinit
)
source `wakeonlan --autocomplete-source`
- If you haven't already done so, you will need to enable script execution on your machine.
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
- Remove "mark of the web" from the auto-complete script:
Unblock-File -Path $(wakeonlan --autocomplete-source)
- Find the location of your profile file:
echo $profile
- If it doesn't exist, create it. Then add the following to its content:
. $(wakeonlan --autocomplete-source)