1

I am able to connect shell channel using Jsch then i have to execute subsequent commands, I have read the below post Multiple commands through Jsch Shell

And I have tried as like below

cmd1 ; cmd2 ; cmd3,
cmd1 && cmd2 && cmd3

But the cmd1 one is the UNIX server login script so even if I give the below commands in putty

cmd1 ; cmd2 ; cmd3,

I am not able to execute all three at one instance, only cmd1 is executing and so not working using Jsch also.

As cmd1 one is for login, so usually in putty I will execute cmd1 then once login into unix server, then I will execute cmd2;cmd3;

So first I want to execute cmd1 Once I am done with the unix server login, I have to execute the all remaining scripts/commands.

 First execution :cmd1-Login,
 second execution cmd2;cmd3;

Please give me any suggestion to solve this issue.

Note: I have tried the below also.

cmd1\ncmd2\ncmd3"
Community
  • 1
  • 1
edr007
  • 11
  • 5

1 Answers1

-1
shellStream.println(command); 
           shellStream.flush();
Thread.sleep(10*4000)

solved the issue,after adding sleep after the flush

edr007
  • 11
  • 5