| Author |
Issue in executing System Command through Java
|
ashwin bala
Ranch Hand
Joined: Dec 07, 2009
Posts: 30
|
|
Hi,
I am trying to execute a system command through java.I am trying to check whether a particular service is running in a
remote PC.When i execute a same command in local PC i.e. without IP Address, then i am getting proper output response.But
when i use remote IP Address and BufferedReader to get the response ,the application is getting hang after
BufferedReader.readLine() method call.. I have attached the code which i have written.
The execution stops after line 17: bufferedReader.readLine(); with out any error.Waiting for the reply. Thanks in advance..
|
 |
Ranganathan Kaliyur Mannar
Bartender
Joined: Oct 16, 2003
Posts: 948
|
|
Hi ashwin,
This question has nothing to do with EJB. Please CarefullyChooseOneForum before posting. I will be moving this thread to an appropriate forum.
|
Ranga.
SCJP 1.4, OCMJEA/SCEA 5.0.
|
 |
Ranganathan Kaliyur Mannar
Bartender
Joined: Oct 16, 2003
Posts: 948
|
|
This probably means the command threw an error. And you are reading only the input stream and not the error stream.
As you are dealing with Runtime, I will point you out to one of the most important articles regarding this: When Runtime.exec() won't
|
 |
ashwin bala
Ranch Hand
Joined: Dec 07, 2009
Posts: 30
|
|
Dear Ranganathan,
I went through the article.They have mentioned about my problem in page 2.But When i tried the solution and guidelines
still i am facing the same problem.And all the right example which they have mentioned were not working when i used my command(sc <ipaddress> query <servicename>) instead "JAVAC"
which is mentioned there.
Thanks & Regards,
Ashwin kumar
|
 |
Ranganathan Kaliyur Mannar
Bartender
Joined: Oct 16, 2003
Posts: 948
|
|
|
Did you then change your code as provided in page 4 (GoodWindowsExec)? If so and if you still face the problem, did you try and run the command from command line first? how do you run it and what happens when you do that?
|
 |
ashwin bala
Ranch Hand
Joined: Dec 07, 2009
Posts: 30
|
|
|
Yes . I tried it.Every time ,things are getting blocked after the readLine statement.
|
 |
Ranganathan Kaliyur Mannar
Bartender
Joined: Oct 16, 2003
Posts: 948
|
|
|
No, I mean, what happens when you execute the command directly - outside the program?
|
 |
ashwin bala
Ranch Hand
Joined: Dec 07, 2009
Posts: 30
|
|
|
I am able to get the status(running/stopped) of the service and other details without any problem.
|
 |
Paul Clapham
Bartender
Joined: Oct 14, 2005
Posts: 16487
|
|
|
Is that "sc" command one of those annoying commands which pop up a dialog box to tell you something, and wait for you to click OK? If so, look for a command option which tells the command not to do that.
|
 |
 |
|
|
subject: Issue in executing System Command through Java
|
|
|