Last active
December 13, 2015 17:08
-
-
Save seandenigris/4945462 to your computer and use it in GitHub Desktop.
Pharo Smalltalk SSH/SFTP Client
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"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