LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-22-2011, 03:32 PM   #1
mrm5102
Member
 
Registered: Apr 2011
Location: Philadelphia
Posts: 165

Rep: Reputation: 3
Remotely Reboot Linux Box From a Windows PC.


Hello,

We have a Linux Computer at work that occasionally has some problems and needs to be rebooted. But the problem is that the manager of that Dept isn't the most technical person in the world and would like to make this as painless as possible for her.

She is running Windows XP Pro. If it were a Linux machine she was running I would probably just write a little simple Expect script that would ssh to the server and send the "shutdown -r now" command and that would be it. But how would I go about doing that on a windows machine. Is there a way to write an Expect script and make it executable in windows? So all she would have to do is "Click the icon" and that's it?


Thanks,
Matt
 
Old 08-22-2011, 03:38 PM   #2
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886
At first, wouldn't it be better to fix the issues then to reboot the server to fix the symptoms?

To your problem, just use a command line client for SSH in Windows that can do key based authorization and allow her account to reboot the machine using sudo. This way you can write a simple batch script she can click on.
 
Old 08-22-2011, 03:39 PM   #3
millgates
Member
 
Registered: Feb 2009
Location: 192.168.x.x
Distribution: Slackware
Posts: 852

Rep: Reputation: 389Reputation: 389Reputation: 389Reputation: 389
hi,
here's what i found with a quick google search.
is that what you need?
http://fixunix.com/ssh/253629-how-pa...h-execute.html
 
Old 08-22-2011, 03:46 PM   #4
mrm5102
Member
 
Registered: Apr 2011
Location: Philadelphia
Posts: 165

Original Poster
Rep: Reputation: 3
TobiSGD,

Quote:
At first, wouldn't it be better to fix the issues then to reboot the server to fix the symptoms?

To your problem, just use a command line client for SSH in Windows that can do key based authorization and allow her account to reboot the machine using sudo. This way you can write a simple batch script she can click on.
Well I think the problem is usually another server that that server connects to. Somehow their connection gets interrupted and the easiest way to fix it is to just do a simple reboot.


millgates,

Quote:
hi,
here's what i found with a quick google search.
is that what you need?
http://fixunix.com/ssh/253629-how-pa...h-execute.html
It's funny you should post that link, because I came across that very same one. But I wanted to see if anyone had other ideas, never used Putty before. (There's more than one way to skin a cat lol)...

Do you know to use ExtraPutty to send commands from I guess another text like file with a separate command on each line?


Thanks,
Matt
 
Old 08-22-2011, 04:29 PM   #5
millgates
Member
 
Registered: Feb 2009
Location: 192.168.x.x
Distribution: Slackware
Posts: 852

Rep: Reputation: 389Reputation: 389Reputation: 389Reputation: 389
Quote:
Originally Posted by mrm5102 View Post
millgates,

It's funny you should post that link, because I came across that very same one. But I wanted to see if anyone had other ideas, never used Putty before. (There's more than one way to skin a cat lol)...
That's true For example, you may write a script on the linux machine that checks for incoming logins in a cycle and if it detects one, it reboots the pc ) but that's probably a stupid idea ))

Quote:
Originally Posted by mrm5102 View Post
Do you know to use ExtraPutty to send commands from I guess another text like file with a separate command on each line?
well i never actually tried it, but i guess if you want to run multiple commands, you can put them in a script on the linux machine and run it with a single command via ExtraPutty
 
Old 08-22-2011, 04:57 PM   #6
mrm5102
Member
 
Registered: Apr 2011
Location: Philadelphia
Posts: 165

Original Poster
Rep: Reputation: 3
Millgates,

Quote:
That's true For example, you may write a script on the linux machine that checks for incoming logins in a cycle and if it detects one, it reboots the pc ) but that's probably a stupid idea ))
Actually that doesn't sound too bad. I could do something like just create a user on the Linux box ONLY for this one purpose. And like you said, if it gets a login attempt from that one and only user, then it will run a script or something. I like it... That would basically bypass any need to have to run any kind of script from Windows, and the person who is going to use it already knows how to login. So that's a plus plus...


Thanks for the suggestion, I'll give it a try when I get back to work tomorrow and let you know how it goes.


Thanks again,
Matt
 
Old 08-22-2011, 05:41 PM   #7
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,681

Rep: Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894
plink will do automated connections.
http://the.earth.li/~sgtatham/putty/.../Chapter7.html
 
Old 08-23-2011, 08:08 AM   #8
mrm5102
Member
 
Registered: Apr 2011
Location: Philadelphia
Posts: 165

Original Poster
Rep: Reputation: 3
Michaelk,

I'll check that out thanks.


-Matt
 
Old 08-23-2011, 08:31 AM   #9
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,649
Blog Entries: 4

Rep: Reputation: 3934Reputation: 3934Reputation: 3934Reputation: 3934Reputation: 3934Reputation: 3934Reputation: 3934Reputation: 3934Reputation: 3934Reputation: 3934Reputation: 3934
It's axiomatic that a Linux box (and a Windows box, for that matter...) ought not need to be "rebooted." Tools exist ... Nagios, and others ... which can monitor the network connection and automatically restart it.

But, even so, the problem needs to be diagnosed and repaired. (Look at the system log files on both of the machines in question.) Network connections should not "go down unexpectedly." Maybe there's a timeout or something.

When and if things like this do happen, the computer should be perfectly capable of issuing the necessary corrective action with no human intervention required.

I have quite routinely encountered Linux systems (and Windows systems, for that matter ...) which have 'up times' of more than a year. They are never "rebooted," and they never need to be.

Last edited by sundialsvcs; 08-23-2011 at 08:32 AM.
 
Old 08-23-2011, 10:54 AM   #10
mrm5102
Member
 
Registered: Apr 2011
Location: Philadelphia
Posts: 165

Original Poster
Rep: Reputation: 3
sundialsvcs,

Quote:
It's axiomatic that a Linux box (and a Windows box, for that matter...) ought not need to be "rebooted." Tools exist ... the one mentioned, or Nagios, and others ... which can monitor the network connection and automatically restart it.

But, even so, the problem needs to be diagnosed and repaired. (Look at the system log files on both of the machines in question.) Network connections should not "go down unexpectedly." Maybe there's a timeout or something.

When and if things like this do happen, the computer should be perfectly capable of issuing the necessary corrective action with no human intervention required.

I have quite routinely encountered Linux systems (and Windows systems, for that matter ...) which have 'up times' of more than a year. They are never "rebooted," and they never need to be.
Yea your right, that would be the best option. Not sure where to look for the errors though...
Do you know where/what logs I should look at to find the problem? It's basically two computers that somehow get a connection through a flash script.

I dunno if it helps to narrow down what logs to look at but it works like this:
The computer running the flash script connects to the other and pulls out some data and displays it using the flash "video". This program that a coworker wrote contains one flash file (.swf) and one HTML file. To run it you would right-click the HTML file and run it in Firefox. The "video" is then displayed in Firefox somewhat like a slideshow of data.


Thanks,
Matt
 
Old 08-23-2011, 11:57 AM   #11
frieza
Senior Member
 
Registered: Feb 2002
Location: harvard, il
Distribution: Ubuntu 11.4,DD-WRT micro plus ssh,lfs-6.6,Fedora 15,Fedora 16
Posts: 3,233

Rep: Reputation: 406Reputation: 406Reputation: 406Reputation: 406Reputation: 406
one solution i've seen on dd-wrt (though probably a horrible idea on a production server) would be to create a user 'reboot' with permissions to reboot the system, then set it's shell to /sbin/reboot, thus simply logging in with that user triggers a reboot, though unless you can restrict how that account gets accessed that would probably be a last ditch idea
 
Old 08-25-2011, 02:06 PM   #12
mrm5102
Member
 
Registered: Apr 2011
Location: Philadelphia
Posts: 165

Original Poster
Rep: Reputation: 3
Hey Guys,

Thanks for everyone's help. And MillGates thanks for the suggestion with a user whose sole purpose would be to restart the computer, got it working and it works perfectly.

Thanks again,
Matt

Last edited by mrm5102; 08-29-2011 at 01:05 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Remotely Shutdown Debian Box from Windows. umatur Debian 11 07-26-2006 06:59 AM
accessing linux box remotely watts3000 Linux - Newbie 5 12-31-2005 06:13 AM
Anyone know a command to remotely reboot a Windows box? xwil Linux - Software 6 04-20-2005 11:57 AM
linux box to remotely use mac os x ip for http Samsara Linux - Networking 3 01-31-2005 09:26 AM
remotely control linux box thevariegator Linux - Newbie 23 03-21-2003 10:56 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:40 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration