Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


How to log an error when executing a rsh command  from Java program

Posted on 2003-03-18
Medium Priority
Last Modified: 2010-03-31

 I am trying to execute an rsh command from the java program. I dont have problems doing this. But when this command has some problem (like Permission Denied, no such command on remote machine etc), It doesn't give me the errors.
(If you execute the same command at the command prompt, it gives these details)

Is there a way to write the results the rsh command execution into a file when executing from the Java program?

For ex.  
when I execute this command on the commmandprompt, all the results are nicely goes into t.out
rsh <remoteMachine> -n -l <userId>  "ls" >& t.out

but when I execute from the java program, it is not.

thanks in Advance.

Question by:kpamu
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
LVL 35

Accepted Solution

girionis earned 300 total points
ID: 8162905
 I guess you execute it by using the Runtime.gtRuntime().exec() method. If yes then all you have to do is to get the input/output stream of the Process class and write them to a file.

Author Comment

ID: 8168018
Thanks for the answer. It works now.


Author Comment

ID: 8168029
Your answer really helped. Thanks a lot.
LVL 35

Expert Comment

ID: 8168078
 Thank you for the points. I am glad I helped :-)

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses

704 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question