rasprm3
Posts: 195
Joined: Sun Jan 20, 2013 1:27 am

Re: Raspberry pi as a Wake on Lan source

Sun Mar 17, 2013 10:20 pm

Success! :D A cron job started the computer.

I've got my weekly times added in. If it's all working, I think I'm done. I'll find out later tonight and tomorrow.

Thanks for everyone's help and input.

I'm going to stick the Pi on the shelf connected up. Once everything's going ok, I can disconnect the monitor, mouse, and keyboard to save some space.

Putty might be a future option.

It would be kind of interesting to be more flexible with the times, ie I know I'll be back at x-time that day so I set a one-time cron job for that. Or I could just hit the power button myself when I return, too....

User avatar
rpdom
Posts: 15601
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Raspberry pi as a Wake on Lan source

Mon Mar 18, 2013 6:56 am

Congratulations on your progress :-)

Rather than using cron for a one-time job, you could use "at".

Code: Select all

[email protected]:~$ at 18:00 thursday
warning: commands will be executed using /bin/sh
at> /usr/bin/wakeonlan aa:bb:cc:dd:ee:ff
at> <EOT>
job 12 at Mon Mar 18 06:56:00 2013
[email protected]:~$
Press Ctrl-D to generate the "<EOT>" character.

Date format is quite flexible. "at now + 15 minutes" will work, for example

skiboysteve
Posts: 4
Joined: Tue Mar 19, 2013 1:36 am

Re: Raspberry pi as a Wake on Lan source

Tue Mar 19, 2013 1:57 am

Hello!

Thank you so much for helping get this up and running. I've wanted to do the exact same thing and now that I found this post, I am very happy! I just followed your instructions and installed the wakeonlan utility to my raspberry pi... but I can't get the cron job to work.

Invoking the utility from the terminal directly (through putty) works fine (computer wakes up), and I can edit my cron list via crontab... but after saving my changes the execution just never happens. Its like the schedule event never fires.

I tried doing "man crontab" and I get "man: command not found". I tried doing "at now + 15 minutes" and I get "at: command not found".

I'm using raspbmc (http://www.raspbmc.com/) as my distribution... is this distribution gimpy for some reason? I also tried "sudo crontab -e" and that file had no jobs in it. So I added my job to that and saved. That didn't work either

Ideas?

Thanks!!

skiboysteve
Posts: 4
Joined: Tue Mar 19, 2013 1:36 am

Re: Raspberry pi as a Wake on Lan source

Tue Mar 19, 2013 2:19 am

figured it out. man and at were not installed. when I installed at, It threw an error saying it couldn't write the atd.pid file. some googling showed there should be a pid service running... and when I checked it wasn't. there also wasn't a cron service running.

doing a "sudo cron" started the service and now everything works.

now I need to figure out why the service didnt run at boot,

skiboysteve
Posts: 4
Joined: Tue Mar 19, 2013 1:36 am

Re: Raspberry pi as a Wake on Lan source

Tue Mar 19, 2013 2:34 am

ah figured it out. raspbmc doesn't start the cron service and even after I tried to edit the start up services... it didn't fix it. there was some other start up service explicitly disabling cron.

thankfully I found this:
http://forum.stmlabs.com/showthread.php?tid=3233

which explains there is a setting in the raspbmc GUI (xbmc -> programs -> rasbpmc -> system settings -> cron scheduler) to turn on cron

woohoo!

rasprm3
Posts: 195
Joined: Sun Jan 20, 2013 1:27 am

Re: Raspberry pi as a Wake on Lan source

Tue Mar 19, 2013 11:47 am

Cool.

How do you set up and use Putty? I hadn't thought that far ahead. I'd like to be able to tweak my times just a bit and I don't want to set up the monitor again.

skiboysteve
Posts: 4
Joined: Tue Mar 19, 2013 1:36 am

Re: Raspberry pi as a Wake on Lan source

Tue Mar 19, 2013 9:16 pm

no setup required. just download putty (its a stand alone exe) and run it. type in the IP of the pi and log in with username "pi" password "raspberry" (or whatver you have changed it to).

when you're done type "exit"

rasprm3
Posts: 195
Joined: Sun Jan 20, 2013 1:27 am

Re: Raspberry pi as a Wake on Lan source

Tue Mar 19, 2013 11:03 pm

Interesting.... I wasn't planning on messing with Putty yet, but I'm lazy and Putty sounds easier than setting up the monitor again (esp in the long run).

Where do I get Putty?

When I run it (?) and enter the ip address, name, password.... Do I end up at the command line/terminal on the Raspberry Pi? That would be great, if I can change the cron job times from there. I'll won't have to even touch the Pi that way.


Working...
http://en.wikipedia.org/wiki/PuTTY
Gave me this...
http://www.chiark.greenend.org.uk/~sgtatham/putty/
http://www.chiark.greenend.org.uk/~sgta ... nload.html
I picked the top one, recognizing ssh.


That was easy enough. I've got the exe. Nothing to install. Just run the exe.
ip address is correct. It pings from a Windows command line. I get the ip address terminal. But...
pi is the default account, right? pi I put that in. It says [email protected]
I keep getting access denied on my password. I've tried many times. I know it's the right password. I wrote it down.
Wrong port or something like that?

Do I need to install ssh on the Raspberry Pi itself? It's essentially fresh out of the box with wakeonlan, upgrades, and updates done.

http://cplus.about.com/od/raspberrypi/a ... rry-Pi.htm
http://www.hobbytronics.co.uk/raspberry-pi-ssh

I can get up to the log in as terminal window.


Phew.. Got it. Finally. It's lowercase.... pi.


:D That is so cool. Dang. I'm impressed. (I must be easily impressed.) Now I can tweak my wakeonlan times. Nice.
I set it on my taskbar to make it super easy. Saved my Raspberry Pi ip address. I just need to remember....
crontab -e
ctrl o to save
ctrl x
and exit for the terminal.


Very cool. Thanks. :) I just have the Ethernet cable, power, and Raspberry Pi off on the shelf. No need for a keyboard, mouse, more monitor any more for my use of it.
Last edited by rasprm3 on Tue Mar 19, 2013 11:37 pm, edited 1 time in total.

rasprm3
Posts: 195
Joined: Sun Jan 20, 2013 1:27 am

Re: Raspberry pi as a Wake on Lan source

Tue Mar 19, 2013 11:33 pm

Just to check... More serious concern.... Security.

I thought I'd have to enable ssh on the Raspberry Pi and that might open it up a bit.

If I've got a router to my ISP and the Pi and my computer connected to that.... Is there a weak point? My computer has its firewall and av/protection stuff so that would be safe, except for having anything device inside my 'network' here. Network of two now.

I thought PuTTY would install more and I'd be enabling ssh on the Pi. But it looks like PuTTY is just asking and connecting.... For someone to get in... They'd have to know my router's ip address, right? Although someone could just be pining random ip addresses and hit mine. But they have to get into the router first right? And then get in the Pi, which would mean using my name and password (pw being unique now). Or they could go for my computer.

I'm thinking there's realistically nothing to worry about, right? ip address/through the router, figure out the Raspberry Pi address, name, password... then on to my regular computer.... Lots of hoops to jump through. It's probably just as easy to get through the router and go straight to my computer, right? Windows. I guess I'm thinking this because my regular computer has a protection suite. The Raspberry Pi doesn't have anything, except the changed password. But it's Linux....

rasprm3
Posts: 195
Joined: Sun Jan 20, 2013 1:27 am

Re: Raspberry pi as a Wake on Lan source

Tue Mar 19, 2013 11:39 pm

Another basic question....

GNU Nano. How do I make a #? That's remarking something out, right? Like REM or :: on a Windows command prompt? (It must be, of course.) I just don't see what key command does that on Nano.

rasprm3
Posts: 195
Joined: Sun Jan 20, 2013 1:27 am

Re: Raspberry pi as a Wake on Lan source

Tue Mar 19, 2013 11:55 pm

That is just cool. PuTTY makes it much better. Much, much more streamlined that I even imagined when I planned out this project.

I've tweaked my wakeonlan times around by just a few minutes now. I can nudge them around precisely, so the computer could power on just a few minutes before I typically get home. Or I can set a one time power on time... Very nice. Very nice. Waaaaay better than a single BIOS wake.

User avatar
rpdom
Posts: 15601
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Raspberry pi as a Wake on Lan source

Wed Mar 20, 2013 6:40 am

rasprm3 wrote:Another basic question....

GNU Nano. How do I make a #? That's remarking something out, right? Like REM or :: on a Windows command prompt? (It must be, of course.) I just don't see what key command does that on Nano.
I don't use nano much, but general I just use the # key ;)
It could be that your keyboard mapping (in PuTTY?) is off.

My # key (on UK keyboards) is next to the Enter key. I believe US keyboards have it on shift-3.

Yes, # is a comment in most files, but not all (C comes to mind here).

rasprm3
Posts: 195
Joined: Sun Jan 20, 2013 1:27 am

Re: Raspberry pi as a Wake on Lan source

Wed Mar 20, 2013 12:06 pm

It was just that # key that was off.

Ah good. It's working through PuTTY. It wasn't working the other day with the keyboard attached. It was just that one key. Strange. Not a problem now though.

rasprm3
Posts: 195
Joined: Sun Jan 20, 2013 1:27 am

Re: Raspberry pi as a Wake on Lan source

Tue Dec 15, 2015 11:25 am

Hey... Resurrected my Raspberry Pi. Actually, just reconnected it. I switched ISP's, and was afraid to connect it again for a long time. I had my modem straight to the computer for a while. Yesterday, I added the router back in which means the Pi can reconnect... And I've got wake on lan again. Yeh! (A techier person and the ISP themselves told me the modem would need to be bridged so the router could hand out DHCP addresses. I didn't want to deal with the hassle of calling the ISP for that. Yesterday, I got tired of the Pi just sitting on the shelf, so I reconnected thing. Everything's just working. No need to contact the ISP...yet. Hope everything sticks. Connected, power cycled the modem, got an internet connection right away.)

The Pi was powered on, sitting on the shelf the whole time. I did apt-get update and upgrade. 5-10 minutes later, if that, (and did a reboot. I'm from the Windows side.) it was all back to normal. Reviewed this post since I had the same questions. Understood my cron job well enough.

Computer was on when I came home from work. (Then I left the computer on overnight... :roll: so no second test this morning.)

Thanks again for the help and advice on this forum. I'm looking forward to having WOL back with the Pi.

Ph9214
Posts: 1
Joined: Tue Mar 29, 2016 1:54 am

Raspberry Pi 0 as remote receiver to power on computer

Tue Mar 29, 2016 2:01 am

So I was thinking of doing a similar thing, but with a pi 0 and have it read the power on signal from my tv remote to turn on the attached computer, can anyone recommend something that will help me with that, I think I know how to do this, but detecting the ir signal with a python script and then using python to send a terminal command sounds a little tricky. Also I would prefer if I could do it over wifi.


PS. I bought these ir recovers in case you were wondering: http://www.ebay.com/itm/5Pcs-IR-Receive ... SwKPNTzQ49

rasprm3
Posts: 195
Joined: Sun Jan 20, 2013 1:27 am

Re: Raspberry pi as a Wake on Lan source

Thu Feb 23, 2017 1:34 am

Back in 2017... More than one computer connected to the router now. The raspberry pi has been doing its WOL job now for a long time.

Since I have two computers and the pi connected, I don't have to rely on a timer necessarily to use WOL. I could make a script, right? That way I don't have to type things out each time.

So...
How would I make a script? I'm using Putty to terminal into it.

It's using Nano I believe to edit the crontab file.

It must be something like.... filename -e and then the usual nano key combos to edit and save a file.

To run the file, it's probably just typing the file name, except this would be a script. Is that saving it/naming it as a .sh file for a bash script?

Looks like this would be the command. It's what's inside the crontab now.
/usr/bin/wakeonlan MA:CA:DD:RE:SS

I could test it out by typing out the command. Then make a script. Then just type the name of the script to run it. Two scripts. One for each computer depending on which I log into.


The final result would be instead of leaning of to hit the power button on the old computer, I could log into the pi, type a script, and the old computer will power on. 8-) :roll: It's more to just write a little script and then to have WOL on demand in case I want to test with it.

Return to “Other projects”