amazon-web-servicesuser-interfaceamazon-ec2terminationstarcluster

Java Runtime Execution - Confirmation issue


I am trying to develop a GUI application that creates and deletes elastic Starcluster clusters in Amazon Elastic Compute 2. So far I have managed to create and use these clusters from the graphic application, but I am running into a problem when I try to delete the clusters. The following is the method I have used to insert commands into the console (from my application):

Runtime rt = Runtime.getRuntimne();    
Process proc = rt.exec("command",null,dir);

The issue is that the system asks me for a yes/no confirmation which I cannot pass through making use of the method used in my application. So far I tried the following:

Runtime rt = Runtime.getRuntimne();    
Process proc = rt.exec("y",null,dir); //y for yes

But the system keeps waiting for an answer, ignoring the command introduced in the application. The following is the log of the actual application requesting a confirmation:

ubuntu@ip-xxx-xxx-xxx-xxx:~$ starcluster terminate myCluster
StarCluster - (http://star.mit.edu/cluster) (v. 0.95.5)
Software Tools for Academics and Researchers (STAR)
Please submit bug reports to starcluster@mit.edu

Terminate EBS cluster myCluster(y/n)?

I would appreciate any thoughts or ideas about the matter. Feel free to ask more information if you consider it necessary to give an appropiate answer.


Solution

  • You need to write your "y" to the process stdin stream.

    Check the answer of Berry Tsakala given to that question: java: how to both read and write to & from process thru pipe (stdin/stdout)