Reputation: 3715
I am a java developer and am assigned to work on a project in which I need to programmatically ssh
into linux boxes and run some unix commands
. After the commands have run, the output of the commands should be collected and displayed on the UI.
I saw a library called sshxcute which can be used to accomplish this. My questions are:
Can get the real time logs from the system where the command is getting executed than getting the logs are the commands have been run.
Can run multiple parallel process on the machines asynchronously.
Upvotes: 0
Views: 506
Reputation: 537
I used jsch java library
ChannelShell channel = openShellChannel();
OutputStream outputStream = channel.getOutputStream();
PrintStream commander = new PrintStream(outputStream, true);
// Print logs
channel.setOutputStream(System.out, true);
// exec the command
commander.println(command);
Upvotes: 1