Languages and Scripting

How to start/stop Windows Services from HP-UX / Linux

 
James Perry
Advisor

How to start/stop Windows Services from HP-UX / Linux

This is an informational post to help others do what I was unable to find documented anywhere else.

For doing multi-tiered product start/stops for backups, maintenance and reboots, it is not unusual to have a script that stops the various tiers. An example being a front end web-server, application server, and database server. If the suite runs on Unix/Linux then this is not an issue as trusts can be established natively to handle this both securely and efficiently. Same goes for an all Microsoft based suite. The problem in this case is that the Web Front End is an IIS server on Windows with the application and database servers on Unix/Linux.

I found one way that uses Cygwin to run and sshd process that would allow the setup of trust for running an application. But that requires a lot of non-native applications that must be configured properly to restart on reboot and adds a lot of complexity. I was certain this was the direction I needed to take.

I went onto a Linux machine and looked at the Samba/CIFS binaries and found the net command. It was also on both an HPUX 11.11 and 11.23 host but required updating to B.02.02.02 to get the required functionality. Testing against various MS servers I found it to be the proper solution without requiring Unix/Linux emulation on Windows for the task. Additionally there are methods to have Samba encrypt the Windows Domain password for maximum security when used in scripts.

To stop a service:
net rpc service stop " -U [%] -S

To start a service:
net rpc service start " -U [%] -S

I hope this keeps others from needing to to hours of Googling to find this tip.
2 REPLIES 2
Steven E. Protter
Exalted Contributor

Re: How to start/stop Windows Services from HP-UX / Linux

Shalom,

You can set up a windows desk top to jump onto a Unix or Linus system and even run commands start and stop.

Windows itself has been structured in such a way to prevent that.

There is a service for Windows Called Unix Services that can be installed and provide some interoperability with Unix.

For a Linux or Unix machine to jump on a Windows machine and run commands is much more difficult.

There are ssh servers for Windows, no doubt, but do they provide the ability to run services and commands in batch mode or as administrator. The answer to this question is I personally do not know.

The better path to go if possible is to host the web portion of this application on a apache sever running under Unix or Linux where one simple script can control start and stop of all services.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
James Perry
Advisor

Re: How to start/stop Windows Services from HP-UX / Linux

Oh I guess I missed in my stated intent.

What I was explaining was a way to do the process from within a script without having to resort to ssh or remote desktops.

The Samba suite for Unix/Linux provides a very nice set of features to interact between Unix/Linux and Windows.

Cygwin with SSH works as well but the Windows Admins really like the simplicity of the "net rpc" commands for this purpose.