streetcarp
Posts: 3
Joined: Fri Jan 30, 2015 10:58 pm

Remote Reboot from Windows OS w/o SSH?

Fri Jan 30, 2015 11:02 pm

Hello, I would to reboot my pi from a windows machine on the same LAN. It has to be something simple so other users can use it. Something like a .bat file would be perfect. Is there a way to do this? Any suggestions or help would be greatly appreciated! Thanks!

User avatar
default_user8
Posts: 501
Joined: Mon Nov 18, 2013 3:11 am

Re: Remote Reboot from Windows OS w/o SSH?

Fri Jan 30, 2015 11:29 pm

Check out the Pi-Web-Agent in the pi store.
Two heads are better than one, unless one's a goat head.

klricks
Posts: 4812
Joined: Sat Jan 12, 2013 3:01 am
Location: Grants Pass, OR, USA
Contact: Website

Re: Remote Reboot from Windows OS w/o SSH?

Sat Jan 31, 2015 1:24 am

streetcarp wrote:Hello, I would to reboot my pi from a windows machine on the same LAN. It has to be something simple so other users can use it. Something like a .bat file would be perfect. Is there a way to do this? Any suggestions or help would be greatly appreciated! Thanks!
You are wanting to send reboot command over LAN without SSH? Any other method, (if one exists), you can do over LAN will be more complicated than SSH.
You might look into using Macro Recorder software in Windows. You could assign a single key-press or Function key to open PuTTy, login and issue reboot command then close PuTTY.
Go here for my RPi writeup. Basic config, Serial Port add-on etc:
http://blackeagle12.net/Comp/RPi/Rpi.html Click contact icon then world icon --->

B.Goode
Posts: 4631
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: Remote Reboot from Windows OS w/o SSH?

Sat Jan 31, 2015 8:18 am

streetcarp wrote:Hello, I would to reboot my pi from a windows machine on the same LAN. It has to be something simple so other users can use it. Something like a .bat file would be perfect. Is there a way to do this? Any suggestions or help would be greatly appreciated! Thanks!
Why NOT use ssh? The end-user does not have to know that is what is being used. ssh does not have to be used only for interactive logins - it can run single commands too.

Set up ssh on windows to work with a public/private keypair, so no password is required for access to the RPi.

Then write a trivial reboot_pi.bat on the windows machine that does the equivalent of

Code: Select all

ssh pi@my_rpi_ip reboot_from_win
where the reboot_from_win script on the RPi simply does whatever you need to do to reboot it.

PuTTY (an ssh client) on Windows already has the ability to 'send remote command' built in.

The end user on the Windows machine has only to run (or click on) the reboot_pi.bat script: all the complexity is handled by the scripts.

If you don't want to use ssh you could try a serial console connection from Windows to the RPi. The logic of the scripts would be similar.

FM81
Posts: 517
Joined: Wed Apr 17, 2013 4:33 pm

Re: Remote Reboot from Windows OS w/o SSH?

Sat Jan 31, 2015 8:29 am

Without SSH you're somewhere in between 'very difficult' and 'impossible' ... :)
But the PUTTY-package also includes the commandline-tool

Code: Select all

plink.exe
You can give all your needed stuff in a BAT or CMD on the windows-machine and execute it by a simple click.

Greetings, FM_81
A: What does the command 'cat /dev/urandom', can you tell me please?
B: Yeah, that's very simple: It feeds your cat with radioactive material!

User avatar
default_user8
Posts: 501
Joined: Mon Nov 18, 2013 3:11 am

Re: Remote Reboot from Windows OS w/o SSH?

Sat Jan 31, 2015 12:50 pm

Pi-Web-Agent in the pistore will allow any user to open a webpage and perform a number of operations(reboot being one option). No ssh no telnet just open a webpage enter a user and password thats it.
Two heads are better than one, unless one's a goat head.

streetcarp
Posts: 3
Joined: Fri Jan 30, 2015 10:58 pm

Re: Remote Reboot from Windows OS w/o SSH?

Sat Jan 31, 2015 12:54 pm

I didn't realize it at first but what I really meant in I didn't want a user to have to fire up putty or do anything more than launch a single file. Plink it it is! Threw a bat file together, tested and worked! Thank you to all who replied!

hippy
Posts: 2291
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Remote Reboot from Windows OS w/o SSH?

Sat Jan 31, 2015 10:09 pm

FM81 wrote:Without SSH you're somewhere in between 'very difficult' and 'impossible' ... :)
Hardly. As it's all on the same LAN a few lines of python can have a server running on the Pi which can be triggered to invoke a reboot or shutdown. All you have to do is trigger it from a browser URL, a python or other program on the PC.

streetcarp
Posts: 3
Joined: Fri Jan 30, 2015 10:58 pm

Re: Remote Reboot from Windows OS w/o SSH?

Sat Jan 31, 2015 11:12 pm

hippy wrote:
FM81 wrote:Without SSH you're somewhere in between 'very difficult' and 'impossible' ... :)
Hardly. As it's all on the same LAN a few lines of python can have a server running on the Pi which can be triggered to invoke a reboot or shutdown. All you have to do is trigger it from a browser URL, a python or other program on the PC.
That's kind of where I thought I was going to go with this from the beginning.. I can do basic stuff with python, but triggerining from another PC is where I'm at a loss.

User avatar
DougieLawson
Posts: 30213
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: Remote Reboot from Windows OS w/o SSH?

Sun Feb 01, 2015 12:21 am

Try this:

cd /home/pi
mkdir /home/pi/cgi-bin
nano /home/pi/rebootSrv.py

Code: Select all

#!/usr/bin/python

import CGIHTTPServer

def main():
  server_address = ('', 6502)
  handler = CGIHTTPServer.CGIHTTPRequestHandler
  handler.cgi_directories = ['/cgi-bin']
  server = CGIHTTPServer.BaseHTTPServer.HTTPServer(server_address, handler)
  try:
     server.serve_forever()
  except:
     server.socket.close()

if __name__ == '__main__':
  main()
nano /home/pi/cgi-bin/reboot.py

Code: Select all

#!/usr/bin/sudo /usr/bin/python
import time
import os

print "Content-type: text/html\r\n\r\n"
print "<html><head></head><body>"
print "<H1>"+time.strftime('%H:%M:%S')+"</H1>"
print os.popen('reboot').read()
print "</body></html>"
chmod 755 /home/pi/rebootSrv.py
chmod 755 /home/pi/cgi-bin/reboot.py
/home/pi/rebootSrv.py &

Point your windows browser at: http://pi.local:6502/cgi-bin/reboot.py # change pi.local to the IP address of your machine

How's that for my 10,000th post on the forum?
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

Since 2012: 1B*5, 2B*2, B+, A+, Zero*2, 3B*3

Please post ALL technical questions on the forum. Do not send private messages.

User avatar
default_user8
Posts: 501
Joined: Mon Nov 18, 2013 3:11 am

Re: Remote Reboot from Windows OS w/o SSH?

Sun Feb 01, 2015 4:47 am

You DA BOMB Dougie! Congrats on the 10000th post. :)
Two heads are better than one, unless one's a goat head.

slambo
Posts: 6
Joined: Sat Mar 25, 2017 12:03 pm

Re: Remote Reboot from Windows OS w/o SSH?

Sun Oct 08, 2017 8:20 am

Thanks for this - I've spent ages trying to find a straight forward of of remotely rebooting or shutting down. Dougie's solution worked straight away.
Couple of queries though, as this post is almost 3 years old is it still the most effective method?
Once rebooted how do I make sure it's ready to go next time, do I need to put '/home/pi/rebootSrv.py &' somewhere?
Is it possible to reboot multi Pis at the same time from one link.

Thanks again

User avatar
DougieLawson
Posts: 30213
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: Remote Reboot from Windows OS w/o SSH?

Sun Oct 08, 2017 10:20 am

It's still the ugliest thing in the history of ugly things, but don't knock it if it works for you.
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

Since 2012: 1B*5, 2B*2, B+, A+, Zero*2, 3B*3

Please post ALL technical questions on the forum. Do not send private messages.

slambo
Posts: 6
Joined: Sat Mar 25, 2017 12:03 pm

Re: Remote Reboot from Windows OS w/o SSH?

Sun Oct 08, 2017 11:32 am

DougieLawson wrote:
Sun Oct 08, 2017 10:20 am
It's still the ugliest thing in the history of ugly things, but don't knock it if it works for you.
Sorry - certainly wasn't knocking it, but wanted to check before I implemented it on 4 different Pis.

Also sorted out second query, I've put '/home/pi/rebootSrv.py &' in crontab, seems to work.

flautze
Posts: 1
Joined: Thu Oct 19, 2017 2:37 pm

Re: Remote Reboot from Windows OS w/o SSH?

Thu Oct 19, 2017 2:42 pm

Unfortunatley I am not too good with code.
But would it be possible to somehow alter this code so it will Shutdown the Pi - instead of reboot?
Thanks for the help.

User avatar
DougieLawson
Posts: 30213
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: Remote Reboot from Windows OS w/o SSH?

Thu Oct 19, 2017 5:18 pm

Change

Code: Select all

print os.popen('reboot').read()
to

Code: Select all

print os.popen('poweroff').read()
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

Since 2012: 1B*5, 2B*2, B+, A+, Zero*2, 3B*3

Please post ALL technical questions on the forum. Do not send private messages.

Return to “Beginners”

Who is online

Users browsing this forum: No registered users and 29 guests