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

How to create a persistent shell? #3

Closed alexbourne closed 10 years ago

alexbourne commented 10 years ago

A comment in ShellOperations for the cd() method says that to be useful "this requires a persistent shell". I noticed this whilst trying to use it. I was trying to do a cd() then a put() but when the put is executed you are back in the root dir again, not the one cd() moved to...

So exactly how do you create a persistent shell using this library??? I've had a look around the code without success so far...

Please share the secret!!!

dacr commented 10 years ago

For example : SSH.shell("localhost", "test") { sh => sh.execute("ls") sh.execute("uname") import sh._ cd("/tmp") println(pwd) }

Have a look to test("helper methods") in https://github.com/dacr/jassh/blob/master/src/test/scala/fr/janalyse/ssh/SSHAPITest.scala

alexbourne commented 10 years ago

Excellent. I had tried an example like this. The only problem I have now is that I wanted to use the put(...) method from SSH i.e. I need to write some text to a file at the remote location which will be a dir I create in my persistent shell. Any suggestions?!

dacr commented 10 years ago

SSH.shellAndFtp(sshopts) { (sh, ftp) => sh.execute("ls") sh.execute("uname") ftp.get("/proc/stat") ftp.get("/proc/vmstat") }

ftp.put is also available.