Skip to content

Instantly share code, notes, and snippets.

@seandenigris
Last active December 13, 2015 17:08
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seandenigris/4945462 to your computer and use it in GitHub Desktop.
Save seandenigris/4945462 to your computer and use it in GitHub Desktop.
Pharo Smalltalk SSH/SFTP Client
"Set the following variables, some of which have reasonable defaults, for your environment"
The required expect file lives at https://gist.github.com/seandenigris/4945436"
command := 'sftp'. "Tested with ssh and sftp"
userName := 'root'.
ipAddress := ''.
password := ''.
prompt := 'sftp> '.
expectFilePath := '/path/to/expect_file.exp'.
escapedPassword := password copyReplaceAll: '"' with: '\"'.
p := PipeableOSProcess command: '/usr/bin/expect "', expectFilePath, '" ', escapedPassword, ' ', ipAddress, ' ', command.
"Must be non-blocking, or #upToEnd hangs the image"
p setNonBlockingOutput.
"Skip login response from the server"
[ | output |
output := p upToEnd.
lines := output lines.
lines size > 0 and: [ lines last beginsWith: prompt ] ] whileFalse.
p nextPutAll: 'pwd', Character cr asString.
p upToEnd.
"p errorUpToEnd."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment