Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Is it possible to get a response from a ssh server in java code? I am trying to get a response from ssh server from

Is it possible to get a response from a ssh server in java code?

I am trying to get a response from ssh server from my java code with this code, not sure where i am wrong,

public static String runCommandAndReturn(String hostName, String username, String password, String command, String sshUser) throws IOException, OperationNotSuccessfulException { connect(hostName, username, password); clientChannel = session.createChannel(ClientChannel.CHANNEL_EXEC, command); ByteArrayOutputStream out = new ByteArrayOutputStream(); String response = out.toString(); clientChannel.setOut(new NoCloseOutputStream(out)); clientChannel.setErr(new NoCloseOutputStream(out)); clientChannel.open().await(); clientChannel.waitFor(Collections.singleton(ClientChannelEvent.CLOSED), 2000); out.reset(); return response; }

my command is like this :

find /app/weblogic/prestige/outbound/mis -type f -name 'VET_20230117*'*. Please help , thanks

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Database Management Systems

Authors: Patricia Ward, George A Dafoulas

1st Edition

ISBN: 1844804526, 978-1844804528

More Books

Students also viewed these Databases questions

Question

7. Identify six intercultural communication dialectics.

Answered: 1 week ago