The Following 10 Users Say Thank You to Cue For This Useful Post: | ||
![]() |
2010-01-22
, 23:47
|
|
Posts: 365 |
Thanked: 98 times |
Joined on Nov 2009
|
#2
|
![]() |
2010-01-23
, 11:09
|
|
Posts: 93 |
Thanked: 36 times |
Joined on Nov 2009
@ Germany / Mainz
|
#3
|
The Following User Says Thank You to mason For This Useful Post: | ||
![]() |
2010-01-23
, 14:11
|
Posts: 840 |
Thanked: 823 times |
Joined on Nov 2009
|
#4
|
thanks for this. Having a small problem with it though. Everytime I try to run it with my MAC, i get a
IndexError: list index out or range
Any idea what the problem is?
Edit: I too hope a WOL app comes to the N900, specially one that will allow you to send magic packets out over the internet as well.
2d
s.sendto(msg, ('<broadcast>', 9))
s.sendto(msg, ('YOUR_DEST', YOUR_PORT))
The Following User Says Thank You to Cue For This Useful Post: | ||
![]() |
2010-01-23
, 16:59
|
Posts: 70 |
Thanked: 6 times |
Joined on Oct 2009
|
#5
|
[Desktop Entry] Encoding=UTF-8 Type=Application Name=WOL Comment=WOL Exec=osso-xterm '/home/user/Myscripts/wakeonlan.sh "XX:XX:XX:XX:XX"' Icon=wol
![]() |
2010-01-23
, 20:21
|
Posts: 840 |
Thanked: 823 times |
Joined on Nov 2009
|
#6
|
Code:[Desktop Entry] Encoding=UTF-8 Type=Application Name=WOL Comment=WOL Exec=osso-xterm '/home/user/Myscripts/wakeonlan.sh "XX:XX:XX:XX:XX"' Icon=wol
is this right for wol shortcut
![]() |
2010-01-23
, 22:57
|
|
Posts: 365 |
Thanked: 98 times |
Joined on Nov 2009
|
#7
|
I think mason is right. it's probably how you entered the mac address. if not, does it display a line number before the error message? that could help.
if your trying to Wake over the internet using the first method only with a custom port, you should try changing this line
to something likeCode:s.sendto(msg, ('<broadcast>', 9))
and have your router forward anything on that port to your LAN broadcast address. which is usually something like 192.168.1.255; or if you have only one machine to wake just forward it to its lan ip.Code:s.sendto(msg, ('YOUR_DEST', YOUR_PORT))
I've not tried WOL over the internet with the first script but you could give it a go.
![]() |
2010-01-23
, 23:54
|
Posts: 70 |
Thanked: 6 times |
Joined on Oct 2009
|
#8
|
![]() |
2010-01-24
, 03:37
|
Posts: 840 |
Thanked: 823 times |
Joined on Nov 2009
|
#9
|
is there any chance that i can make a shortcut to a list of wol clients?
press wol shortcut will bring you to a list, than you can chosse which wol client ( script) will be activated
pygtkeditor ./MyScripts/pclist.cfg
[HomePC] mac="FF:FF:FF:FF:FF:FF" ip="192.168.1.4" user="uername" type="vnc" [OfficePC] mac="FF:FF:FF:FF:FF:FF" ip="192.168.1.5" type="ssh" [UniPC] mac="EE:EE:FF:FF:FF:FF" ip="192.168.1.6" user="me" type="ssh"
pygtkeditor ./MyScripts/pclistwol.sh
#!/bin/sh # Function: get_config_list config_file # Purpose : Print the list of configs from config file get_config_list() { config_file=$1 awk -F '[][]' ' NF==3 && $0 ~ /^\[.*\]/ { print $2 } ' ${config_file} } # Function : set_config_vars config_file config [var_prefix] # Purpose : Set variables (optionaly prefixed by var_prefix) from config in config file set_config_vars() { config_file=$1 #file name config=$2 #set name var_prefix=$3 #prefix variable with this config_vars=$( awk -F= -v Config="${config}" -v Prefix="${var_prefix}" ' BEGIN { Config = toupper(Config); patternConfig = "\\[" Config "]"; } toupper($0) ~ patternConfig,(/\[/ && toupper($0) !~ patternConfig) { if (/\[/ || NF <2) next; sub(/^[[:space:]]*/, ""); sub(/[[:space:]]*=[[:space:]]/, "="); print Prefix $0; } ' ${config_file} ) eval "${config_vars}" } # Set variables for selected pc file="/home/user/MyScripts/pclist.cfg" if [ $# -ne 1 ] then echo "List of PCs:" for cfg in $(get_config_list ${file}) do echo "--- [${cfg}] ---" unset $(set | awk -F= '/^cfg_/ { print $1 }') cfg_ done echo "which do you wish to wake" read cfg set_config_vars ${file} ${cfg} cfg_ else set_config_vars ${file} $1 cfg_ fi #Use config file to perform action eg wol from PC list. /home/user/MyScripts/wakeonlan.py $cfg_mac
The Following User Says Thank You to Cue For This Useful Post: | ||
![]() |
2010-01-24
, 14:51
|
|
Posts: 365 |
Thanked: 98 times |
Joined on Nov 2009
|
#10
|
It may seem complicated at first but it is a small introduction to using linux and a very powerful tool called shell scripts. Most of the things here you may already know. I have tried to explain steps and terms as clearly as I can (almost bordering on patronising but not intended to be) for new linux and N900 users. Having said that I'd like to put a disclaimer that this is not for the faint of heart. Be very careful what you do with your phone and do it at your own risk.
Turn on a PC. WOL
Wake on lan (WOL) is a method to turn on a machine with a "signal" known as a magic packet sent from another device on a network.
Both the machine and the network need to be setup for this, this is not discussed here. I recommend you google for "WOL BIOS" "WOL portforwarding" to setup the machine and network.
There are two ways to send the signal. You only need to use one or the other.
1) get the N900 to send it
2) Use the N900 to tell a router, NAS device or another PC to send it.
1) sending it from the N900 directly
This is probably the easier method. For people who want to wake many machines on their lan and have a router capable of ssh and WOL (eg DD-WRT routers) I recommend method two.
install the pygtkeditor app, this is what you use to write scripts. (applications menu -> more -> app manager -> download ->all)
open an x terminal on the N900 (applications menu -> more -> x terminal)
type the following and press enter to create a directory (folder)
copy paste the script below into the editor. for a guide to copy paste from the browser look at this post and use the stylus not your finger
http://talk.maemo.org/showpost.php?p=443893&postcount=8
at the terminal use this command so that you can execute the script
there is a way to make most of the directory commands here shorter if you want to use the command often, but we'll learn how to create a shortcut on the desktop further down the tutorial anyway.
2) telling a router to send the wake signal
if you followed the step above (sending it from the N900 directly) you don't need to do this section (section 2), you can do both and nothing wrong will happen but there really is no need to do both. if you have network knowledge, a lot of PCs to wake from a WAN, or an always on DDWRT-router/low power PC I'd recommend this over step 1. if you use a DDWRT router first make sure you enable ssh on the router from both the services and managment tab.
Now the script is a lot easier and waking more than one machine in your LAN from a WAN is easier too.
like in section 1) above instead of
Copy paste the short script below and save the file.
if you want to wake from a WAN (usually from outside your house) instead of "192.168.1.1" put your ISP ip or a DYNDNS address and set up port forwarding.
3) turn on AND ACCESS a PC
OK so now we can turn on a PC. This is a guide to access it.
there are two ways to control a PC used here. SSH or VNC. I recommend SSH (and linux ofcourse).
On the N900 install both vncviewer and OpenSSH client so you can do both (applications menu -> more -> app manager -> download ->all)
if your PC is running Windows: install realvnc on it (you can set up SSH but it's difficult on windows)
if your PC is running linux: you need OpenSSH Server or if you want to use VNC it is probably already installed (all you need to do is enable it).
so now we will create a fairly crude script to not only wake but access the PC
open editor
Now this command in the x terminal will wake up (if not already awake), then access the pc with either vnc or ssh
for vnc
Everything we have done so far has been using the command line to write scripts so we can do even more in the command line. we will now create a nice shortcut on the desktop or apps menu to access a certain PC with one click (and probably a password entry or two).
you will need rootsh installed (this is now becoming more dangerous)
also install leafpad if you dont like the vi editor
Lets just hope a WOL app becomes available in extras in the future.
Thank you to everyone for making the forums what it is and I welcome any scripting suggestions from the gurus.
Last edited by Cue; 2010-04-15 at 02:02.