dacr / jassh

High level scala SSH API for easy and fast operations on remote servers.
Apache License 2.0
71 stars 27 forks source link

Can I send a string to stdin when executing an ssh command? #2

Closed alexbourne closed 10 years ago

alexbourne commented 10 years ago

Hi, I'm attempting to run a remote script using jassh. Unfortunately the script requires a user's password to be typed on stdin. Looking through the source I noticed SSHExec has a method giveInputLine(line: String) and possibly combined with SSH.run(...) which hinted this might be possible. I'm a bit of a scala newbie coming from Java so this might be obvious to others, but I wondered a) if this is possible, and b) how I might extend one of the classes to make this work as I don't see any uses of giveInputLine in the source. Many thanks in advance Alex.

dacr commented 10 years ago

Hello, you can take a look to 'become' method in SSHShell class : https://github.com/dacr/jassh/blob/master/src/main/scala/fr/janalyse/ssh/SSHShell.scala . This is something I'd like to improve, with a react, event mechanism. A string pattern is identified then a react code is executed.

dacr commented 10 years ago

Current progress can be seen in that class : https://github.com/dacr/jassh/blob/master/src/main/scala/fr/janalyse/ssh/SSHReact.scala

With that test case : https://github.com/dacr/jassh/blob/master/src/test/scala/fr/janalyse/ssh/SSHReactTest.scala

Take care this is work in progress. I close this issue because this is in fact a new feature that will become available in several weeks, as soon as I will have time to continue to work on it (I'm too busy right now).