Executing Multiple Unix Commands in one SSH Session from Java Program

Joined
Jan 15, 2009
Messages
2
Reaction score
0
Hi,

Iam trying to code in java and wanted to run the commands in the Unix remote servers. I have the following code to run multiple GREP commands from a file in a single session.

But when i execute this, the first command executes successfully, whereas from the next line it says

"Exception Occured
java.io.IOException: A remote execution has already started."



Following is my code snippet :

FileReader fr = new FileReader("grepcommands.txt");
BufferedReader br = new BufferedReader(fr);
String inputscript="";
sess= conn.openSession();
while((inputscript=br.readLine())!=null){
sess.execCommand(inputscript);
}
sess.close();




It would be great if anyone can provide me the solution for this.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top