[StarCluster] EXECUTE STARCLUSTER FROM JAVA CODE

Steve Darnell darnells at dnastar.com
Thu Apr 30 08:41:28 EDT 2015


Shouldn't you be using output streams and readers rather than input ones?

Sent from my iPhone

> On Apr 30, 2015, at 4:22 AM, Andrea La Rizza <andrea.larizza at alef.it> wrote:
> 
> 
> Hi Steve,
> 
> thank you for your replay. I tried with both ProcessBuilder and Runtime. The output is handled as follow:
> 
>                        BufferedReader bfr = new BufferedReader(new InputStreamReader(pr.getInputStream()));
>                        String line = "";
>                        while((line = bfr.readLine()) != null) {
>                        log.append(line+"\n");
> 
> The console does not show any error or message, but i do not receive any output and if i go on aws console nothing have been triggered!
> Il 27/04/15 19:24, Steve Darnell ha scritto:
>> Hi Andrea,
>> 
>> 1. ProcessBuilder is the preferred mechanism for running an external process in Java (introduced in 1.5).
>> 2. External process tend to fail/hang if you do not explicitly handle the standard output/error streams.
>> 
>> http://docs.oracle.com/javase/7/docs/api/java/lang/ProcessBuilder.html
>> 
>> ~Steve
>> 
>> -----Original Message-----
>> From: starcluster-bounces at mit.edu [mailto:starcluster-bounces at mit.edu] On Behalf Of Andrea La Rizza
>> Sent: Monday, April 27, 2015 9:36 AM
>> To: starcluster at mit.edu
>> Subject: [StarCluster] EXECUTE STARCLUSTER FROM JAVA CODE
>> 
>> Hi All,
>> I'm creating a complex project, and what I want to do is to launch the command "starclster start my custer" by pressing a button in a java swing interface.
>> I have created a script called run with the command inside, and what I do in my java cose is:
>> 
>> String[] cmd = new String[2];
>>                          cmd[0] = "sh";
>>                          cmd[1] = "run";
>>                          // create runtime to execute external command
>>                          Runtime rt = Runtime.getRuntime();
>>                          //Process pr = rt.exec("/path/to/script/run");
>>                          Process pr = rt.exec(cmd);
>> 
>> If I run the script from shall it works, i i press the button nothing happens. Is there someone that have done something similar? Thanks.
>> _______________________________________________
>> StarCluster mailing list
>> StarCluster at mit.edu
>> http://mailman.mit.edu/mailman/listinfo/starcluster
> 
> 



More information about the StarCluster mailing list