Connection

server = DO::Server.new('srv1', 'srv1.domain.local', 'root', :key => 
    %w[srv1.pem]

Run

server.run 'uname'
# [email protected] ~ # uname
# Linux

server.run 'uname', '-a'
# [email protected] ~ # uname -a
# Linux srv1.lipsiasoft.net 2.6.18-194.32.1.el5  x86_64 x86_64 x86_64 GNU/Linux

server.run 'mysqladmin -u root -p password "oldone"', 'newpassword'
# [email protected] ~ # mysqladmin -u root -p password 'oldone'
# Enter password: oldone
# mysqladmin: connect to server at 'localhost' failed
# error: 'Access denied for user 'root'@'localhost' (using password: YES)'

Files

server.exist?('~/.ssh')
# [email protected] ~ # test -e ~/.ssh && echo True
# => true

server.read('/etc/redhat-release')
# [email protected] ~ # cat /etc/redhat-release
# => "CentOS release 5.5 (Final)"

Upload/download

server.upload '/tmp/file', '/tmp/foo'
# [email protected] ~ # upload from '/tmp/file' to '/tmp/foo'

server.download '/tmp/foo', '/tmp/file2'
# [email protected] ~ # download from '/tmp/foo' to '/tmp/file2'

Replace

server.replace :all, 'new content', '/tmp/file'
# [email protected] ~ # replace all in '/tmp/foo'

server.read('/tmp/foo')
# [email protected] ~ # cat /tmp/foo
# => "new content"

Replace via regex

server.replace /content$/, 'changed content', '/tmp/foo'
# [email protected] ~ # replace /content$/ in '/tmp/foo'

server.read('/tmp/foo')
# [email protected] ~ # cat /tmp/foo
# => "new changed content"

Append

server.append('appended', '/tmp/foo')
# [email protected] ~ # append to 'bottom' in '/tmp/foo'

server.read('/tmp/foo')
# [email protected] ~ # cat /tmp/foo
# => "new changed contentappended"

Append to top

server.append('---', '/tmp/foo', :top)
# [email protected] ~ # append to 'top' in '/tmp/foo'

server.read('/tmp/foo')
# [email protected] ~ # cat /tmp/foo
# => "---new changed contentappended"

Prompt

server.ask "Please choose"
# [email protected] ~ # Please choose: foo
# => "foo"

server.yes? "Do you want to proceed"
# [email protected] ~ # Do you want to proceed? (y/n): y
# => 0

server.wait
# Press ENTER to continue...