3 category: Ruby libraries
6 * [DAddYE/do](https://github.com/DAddYE/do)
10 server = DO::Server.new('srv1', 'srv1.domain.local', 'root', :key =>
18 server.run 'uname', '-a'
19 # root@srv1 ~ # uname -a
20 # Linux srv1.lipsiasoft.net 2.6.18-194.32.1.el5 x86_64 x86_64 x86_64 GNU/Linux
22 server.run 'mysqladmin -u root -p password "oldone"', 'newpassword'
23 # root@srv1 ~ # mysqladmin -u root -p password 'oldone'
24 # Enter password: oldone
25 # mysqladmin: connect to server at 'localhost' failed
26 # error: 'Access denied for user 'root'@'localhost' (using password: YES)'
30 server.exist?('~/.ssh')
31 # root@srv1 ~ # test -e ~/.ssh && echo True
34 server.read('/etc/redhat-release')
35 # root@srv1 ~ # cat /etc/redhat-release
36 # => "CentOS release 5.5 (Final)"
40 server.upload '/tmp/file', '/tmp/foo'
41 # root@srv1 ~ # upload from '/tmp/file' to '/tmp/foo'
43 server.download '/tmp/foo', '/tmp/file2'
44 # root@srv1 ~ # download from '/tmp/foo' to '/tmp/file2'
48 server.replace :all, 'new content', '/tmp/file'
49 # root@srv1 ~ # replace all in '/tmp/foo'
51 server.read('/tmp/foo')
52 # root@srv1 ~ # cat /tmp/foo
57 server.replace /content$/, 'changed content', '/tmp/foo'
58 # root@srv1 ~ # replace /content$/ in '/tmp/foo'
60 server.read('/tmp/foo')
61 # root@srv1 ~ # cat /tmp/foo
62 # => "new changed content"
66 server.append('appended', '/tmp/foo')
67 # root@srv1 ~ # append to 'bottom' in '/tmp/foo'
69 server.read('/tmp/foo')
70 # root@srv1 ~ # cat /tmp/foo
71 # => "new changed contentappended"
75 server.append('---', '/tmp/foo', :top)
76 # root@srv1 ~ # append to 'top' in '/tmp/foo'
78 server.read('/tmp/foo')
79 # root@srv1 ~ # cat /tmp/foo
80 # => "---new changed contentappended"
84 server.ask "Please choose"
85 # root@srv1 ~ # Please choose: foo
88 server.yes? "Do you want to proceed"
89 # root@srv1 ~ # Do you want to proceed? (y/n): y
93 # Press ENTER to continue...