How could I pass in commands into a terminal that is already running in java (linux) -
i have been researching how run terminal command in java. doing make program can use ssh pc (just project). how keep continuing putting commands in terminal? if run message put in password , if print out messages terminal spits out @ : while((line = in.readline()) != null){ system.out.println(line + "\n");
}
line, few seconds after program stop working. have gui button , if press button run code. me fix issue of stopping , give me information on how continue put commands terminal? thanks.
process p = null; string[] command = {"/bin/sh", "-c", "ssh 192.168.2.100"}; processbuilder pb = new processbuilder(command); string line = null; try { term = pb.start(); } catch (ioexception e1) { // todo auto-generated catch block e1.printstacktrace(); } inputstream = p.getinputstream(); bufferedreader in = new bufferedreader(new inputstreamreader(is)); try { while((line = in.readline()) != null){ system.out.println(line + "\n"); } } catch (ioexception e) { // todo auto-generated catch block e.printstacktrace(); } try { in.close(); } catch (ioexception e) { // todo auto-generated catch block e.printstacktrace(); }
you can not pass argument live jvm, there way in can modify of parameters done using jmx, can connect live jvm , send parameters. taken effect immediately.
hope helps
Comments
Post a Comment