views:

217

answers:

4

I've been asked to find a way to connect from a Linux system to one of several Windows servers. What we need to do ideally is connect to whatever Windows server is causing the trouble, kill a process, and restart the process. Ideally, it would be something that could be put into a script that could be run from the Linux computer. All the solutions I've found so far involve some kind of remote desktop connection, but like I said, a command line solution is preferable? Is this possible? And I apologize...not quite a programming question, but I'm at my wit's end.

+2  A: 

I use Cygwin with OpenSSH server on the Windows box (but it is available without Cygwin in an installer), and can log in over SSH from the Linux box to do stuff with a command line. I don't kill processes, I make builds. But the same concept applies.

Ali A
I suggested Cygwin to the guy in charge of the project. He didn't think installing it on each of the Windows servers just for this one little bit was worth the trouble.
Charasan
You don't necessarily need the whole of cygwin, just rshd/sshd and cygwin.dll - I do a similair thing with rsyncd on windows.
Martin Beckett
A: 

Did you think about the Windows telnet server, and scripting it with expect?

geocar
+1  A: 

Cygwin's default ps/kill doesn't allow you to access Windows processes to kill them.

Use cygwin + openssh + windows services to get an SSH user on the machine.

Once you're in an SSH commandline, you can use standard Win32 tools to kill a process, for instance -

taskkill /f /im notepad.exe

Or add other commandline process tools for Win32.

EDIT : or you can just use ps -elW to view all the windows processes, and then pass that PID into taskkill.

Rizwan Kassim
Hmm...can this work with the Cygwin-free installation of OpenSSH discussed above? If so, I think this might work. Won't know for sure 'till Monday, though :D
Charasan
+2  A: 

This claims to be a port of the sysinternals psexec , I haven't used it but psexec is great

Martin Beckett