Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void main (String args[]) throws IOException {
- String user = "username";
- String password = "password";
- String host = "hostName";
- int port=22;
- Expect expect=null;
- try
- {
- JSch jsch = new JSch();
- // jsch.
- Session session = jsch.getSession(user, host, port);
- session.setPassword(password);
- session.setConfig("StrictHostKeyChecking", "no");
- System.out.println("Establishing Connection...");
- session.connect();
- Channel channel=session.openChannel("exec");
- ((ChannelExec)channel).setCommand("pbrun pbapp wasapp=ksh");
- ((ChannelExec)channel).setCommand("ls -l");
- channel.connect();
- System.out.println("connect succcessfully");
- System.out.println("before command");
- System.out.println("after command");
- InputStream output= channel.getInputStream();
- System.out.println("aafter stream");
- int readByte= output.read();
- StringBuilder outputBuffer=new StringBuilder();
- while(readByte != 0xffffffff)
- {
- outputBuffer.append((char)readByte);
- readByte = output.read();
- }
- System.out.println(outputBuffer.toString());
- String s=outputBuffer.toString();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement