0

I am working on running a shell script from Java. I was able to ssh successfully to a server using JSCH using the steps mentioned [here].

Now my requirement is, I need to ssh to server1 , and then ssh to server2 from server1. After ssh to server2, I need to do su - user. After su, I need to run a shell script by passing parameters.

So I need steeps to login to server2 after connecting to server1 from java. Once ssh into server2, do su and run script.

Any help please suggested.

madhuram2468
  • 41
  • 1
  • 5
  • Since you were able to successfully connect to server1, did you try connecting to server2 from there? It doesn't really sound like you ran into any trouble – keyser May 03 '14 at 14:24
  • You can use a "here document" as mentioned in http://stackoverflow.com/questions/4412238/whats-the-cleanest-way-to-ssh-and-run-multiple-commands-in-bash – shiv May 03 '14 at 14:31
  • @keyser... I tried to ssh to server2 and it worked!! now doing su is the tricky part for me – madhuram2468 May 03 '14 at 15:59

0 Answers0