Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners Need Sample code To check the Windows services status is up or down in Linux mechine
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


manjula
Need Sample code To check the Windows services status is up or down in Linux mechine
0 Answer(s)      a year and 4 months ago
Posted in : Java Beginners


Hi, I did code to check the windows services are up or down that could be worked in only windows box,but my requirement is windows services is up or down ,this has to check that in linux with simple standlon java application please provide any sample code. below code can work in only windows box but i want to test that windows servises is up or down please provide solution

import java.util.*;
import java.sql.*;
import java.io.*;
import java.text.*;
public class doscmd 
 { 
    public static void main(String args[]) 
      { 
        try 
         { 
           Process p=Runtime.getRuntime().exec("sc query browser"); 

BufferedReader reader=new BufferedReader(new InputStreamReader(p.getInputStream())); 

           String line=reader.readLine();
           while(line!=null) 
            { 
              if(line.trim().startsWith("STATE"))

               {

                if (line.trim().substring(line.trim().indexOf(":")+1,line.trim().indexOf(":")+4).trim().equals("1"))
    System.out.println("Stopped");
else
    if (line.trim().substring(line.trim().indexOf(":")+1,line.trim().indexOf(":")+4).trim().equals("2"))
        System.out.println("Startting....");
    else
        if (line.trim().substring(line.trim().indexOf(":")+1,line.trim().indexOf(":")+4).trim().equals("3"))
            System.out.println("Stopping....");
        else
            if (line.trim().substring(line.trim().indexOf(":")+1,line.trim().indexOf(":")+4).trim().equals("4"))
                System.out.println("Running");

  }
   line=reader.readLine(); 
   } 

 } 

 catch(IOException e1) { } 



   } 
 } 

Advertisement
View Answers

Related Tutorials/Questions & Answers:
Need Sample code To check the Windows services status is up or down in Linux mechine
Need Sample code To check the Windows services status is up or down in Linux mechine  Hi, I did code to check the windows services are up or down... is up or down ,this has to check that in linux with simple standlon java
Need sample code
Need sample code  Need code for graph which shows the performance comparission of aprior algorithm and coherent rule algorithm.plz can any one help me i need in a week
Advertisements
need a Sample code - Development process
need a Sample code  i want run the python script in java code by using Runtime class and output should be formed like XML format.please help me. Advanced Thanks, Krishna
Need simple java code to start and stop the remote windows service.
Need simple java code to start and stop the remote windows service.  Hi, I Need simple java code to start and stop the remote windows service. Example:There are two servers 1) Server A and 2) Server B. If a notepad.exe file
Linux Vs. Windows
no licensing fee, whereas Windows must need license.  Linux can be operated on older... Linux Vs. Windows       ...;       Both Linux and Windows works
Need someone to check and modify my simple code - Java Beginners
Need someone to check and modify my simple code   How to write a class that contains Variables that hold hourly rate of pay, number of hours...); } }   Hi Friend, You can use following code: import
Cheap Web Hosting Services in India
Limited (RTPL) provides the best web hosting services on Windows, Linux.... The need of the cheap web hosting services requires those want some specific, concise.... To meet the need of clients, Roseindia provides cheaper web hosting services
need help for writting code in struts action class for check boxes and radio buttons - Struts
need help for writting code in struts action class for check boxes and radio buttons  Hello frnds, i need help from u esteemed and talented people.iwould like to write code in struts action class for check boxes and radio
Sample Ajax Code
Sample Ajax Code  Sample Ajax Code for getting values from another JSP   The below code is helpful to access another Action class...;/SIX> <SEVEN><%= request.getAttribute("STATUS")%><
sample code - WebSevices
sample code  Hi Guys, can any body tell me use of webservices ? I want a sample code using xml with one application server bea weblogic and webserver tomcat   Hi Friend, Please visit the following link
Sample\Practice project on JSP and Web services
Sample\Practice project on JSP and Web services   I wanted to implement\Practice a project using web services. where can I get these details   Please visit the following link: http://www.roseindia.net/webservices
linux desktop on windows without using vn or any other ? - Java Magazine
linux desktop on windows without using vn or any other ?  linux desktop on windows without using vn or any other ?. I have a linux pc and windows xp pc but i am not able to connect the linux pc on windows .why? .windows
Dependant & dynamic drop down list - Follow up
Dependant & dynamic drop down list - Follow up  Thanks for your... down. In my case user can choose more than one row , which is then sent to next...){ System.out.println(e); } %> For the above code, we have created two database tables
Sample Code - Development process
Sample Code   Hi Friend, Give sample code DTO... is generic enough to use for any DTO purpose; therefore, you do not need to design a new class for each DTO. 2.Write or generate the code for the data transfer
java sample code - Java Beginners
java sample code  hai...... i need a full sample program fo inheritance.........  Hi Friend, Please visit the following link: http://www.roseindia.net/java/language/inheritance.shtml Thanks
Cheap Web Hosting Services in Delhi
web hosting services on Windows, Linux and Dedicated web servers at cheaper... of ?best services in cheaper prices'. Check http://www.roseindiahosting.com... Cheap Web Hosting Services in Delhi Roseindia Technologies Private
Sample Code For ArrayLlist - Java Beginners
Sample Code For ArrayLlist   Hi Friend, I want sample code for adding single records and multiple records using ArrayList.Give sample code for Arraylist with realtime application.  Hi I
What is Linux Hosting?
and cloud services. Presently along with Windows hosting services Linux hosting... software that can be accessed by any web developer and services. Linux... services. Before going on the various pros and cons concerning Linux hosting, let
check youtube iframe code
check youtube iframe code  I have a piece of code that checks the youtube embed code in this format: My PHP code looks like this now: //Check Embed Code $embedCode = $postData['embedCode
need of code
need of code  howto convert greyscale image to binary image in java
need code
need code  Create Vehicle having following attributes: Vehicle No., Model, Manufacturer and Color. Create truck which has the following additional... is the required code: import java.util.*; class Vehicle { int
need code
need code  Create Vehicle having following attributes: Vehicle No., Model, Manufacturer and Color. Create truck which has the following additional... is the required code: import java.util.*; class Vehicle { int
need code
need code  Create Vehicle having following attributes: Vehicle No., Model, Manufacturer and Color. Create truck which has the following additional... is the required code: import java.util.*; class Vehicle { int
Sample Code for DTO in WebApplication - Development process
Sample Code for DTO in WebApplication   Hi Friends, Can u explain DTO in webapplication with sample code
Navigate database values using up and down key of keyboard
Navigate database values using up and down key of keyboard In this section, you will learn how to navigate database values using up and down keys... the database values. On pressing the up key, the following code will fetch one by one
Sitemap Linux Tutorial
| Site Map | Business Software Services India Linux Tutorial Section... | Linux Vs. Windows (A Comparison) | Linux Distributions | Running from CDs... | Installing Linux and Windows (Dual Installation) | Getting Started in Linux
I need to launch multiple instances of IE browser from one windows M/C on the another windows M/C
I need to launch multiple instances of IE browser from one windows M/C on the another windows M/C  multiple instances of IE browser from one windows M/C on the another windows M/C
I need to launch multiple browsers installed on another windows M/C from my windows M/C over the network.
I need to launch multiple browsers installed on another windows M/C from my windows M/C over the network.  Please share the java code for the same as soon as possible
need a sample project using java technologies like jsp, servlets, struts
need a sample project using java technologies like jsp, servlets, struts  Hi everybody! I have learnt core java,jdbc,jsp,servlets & struts. Please guide me where can i find sample project like library management, CMS or any
What is Windows Hosting?
hosting need Windows hosting packages can actually be a little costlier than Linux... of a choice as there are only two major hosting types, Windows hosting and Linux... one is the better, Linux or Windows. Though both types of hosting has its
Hibernate sample code - Hibernate Interview Questions
Hibernate sample code  Hi Can any body tell me how to persist inner class,abstract class,final class,and interface in hibernate. From... Hibernet.org.The Hibernate 3.0 core is 68,549 lines of Java code together with 27,948 lines
 

 

 

DMCA.com