This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Ant, Maven and Other Build Tools and the fly likes Start and stop apache service running on a remote server in ANT Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Start and stop apache service running on a remote server in ANT" Watch "Start and stop apache service running on a remote server in ANT" New topic
Author

Start and stop apache service running on a remote server in ANT

Prabha Dhandapani
Ranch Hand

Joined: Sep 11, 2003
Posts: 70
What is the best solution to remotely start and stop the apache service (running as a windows service) from an ANT script. I looked into the exec tag to run it by executing cmd.exe.

We had apache running on Windows 2000 server where we called the sc.exe directly from the ant script to stop and start the apache service. However, we recently migrated to Windows 2003 which has more security at teh OS level so a non administrator user cannot start the sc.exe remotely. What are the other options that can be used to start and stop the apache server from the build script.

Can someone please provide sample ant code to do this ASAP?

Please note that apache is running on a remote server.

Many thanks in advance!
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30356
    
150

Prabha,
Before trying to figure out what to do in Ant, you need to figure out how to start/stop the service remotely. What do the administrators who tightened security recommend?


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Prabha Dhandapani
Ranch Hand

Joined: Sep 11, 2003
Posts: 70
Thanks for the response Jeanne!

The adminsitrators are ok with any solution to start and stop the service remotely as long as they dont have to give the user running the ant script to do this does not need admninstrator rights on the server or giving adminstrator rights to the user but the password is not visible in the ant script or anywhere in the properties.

The administrators are ok with executing any .exe or script , etc on the server locally once we connect to the server (Windows 2003 server).

Thanks,
Prabha
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30356
    
150

Prabha,
One solution is to create a script on the remote machine that calls the start/stop service command. This script can be set to run by any user (or whatever user you run ant as) but "run as" a user that can stop/start the service.

I know this works on UNIX. I haven't used Windows Server, but assume they have something similar.
Mohammed Yousuff
Ranch Hand

Joined: Oct 17, 2007
Posts: 198
Is there any way i can access and restart apache in another development machine ???.. because i have to restart the apache of my friends machine ??? ...

we both are using windows machine, i have to access while his computer has locked....


My Thoughts : http://passion4java.blogspot.com
Try not to become a man of success but rather to become a man of value.
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

Hi there, you might be better off posting this question in the Tomcat Forum.


Cheers, Martijn - Blog,
Twitter, PCGen, Ikasan, My The Well-Grounded Java Developer book!,
My start-up.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Start and stop apache service running on a remote server in ANT