Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 80 lines (55 sloc) 2.937 kb
def7a17 @jamis make this place livable!
jamis authored
1 = Net::SSH::Shell
2
3 == DESCRIPTION:
4
5 Net::SSH::Shell is a library for interacting with stateful (e.g., interactive) shells on remote hosts. It hides (or tries to hide) the potentially complex Net::SSH state machines you'd otherwise need to write to interact with "su" and similar shells.
6
7 One of the significant benefits you get from this library versus using Net::SSH directly is that your shell is _stateful_. With Net::SSH, if you invoke "cd /" in one exec call, and "pwd" in another, the two are done in different shells so the directory change in the first has no effect on the working directory of the second. With Net::SSH::Shell, though, commands are all invoked via the _same_ shell, so changes in directory or additions to the environment all affect subsequent commands.
8
9 == FEATURES:
10
11 * Interact with login shells
12 * Support for "subshell" environments, like "su" or "sudo bash"
13
14 == SYNOPSIS:
15
16 In a nutshell:
17
5a2399a @jedi4ever Corrected typo in Readme Net::SSH.start instead of Net::SSH.Start
jedi4ever authored
18 require 'net/ssh'
def7a17 @jamis make this place livable!
jamis authored
19 require 'net/ssh/shell'
20
5a2399a @jedi4ever Corrected typo in Readme Net::SSH.start instead of Net::SSH.Start
jedi4ever authored
21 Net::SSH::start('host', 'user') do |ssh|
def7a17 @jamis make this place livable!
jamis authored
22 ssh.shell do |sh|
23 sh.execute "cd /usr/local"
24 sh.execute "pwd"
25 sh.execute "export FOO=bar"
26 sh.execute "echo $FOO"
33f3e29 @jedi4ever Example in Readme.DOC on how to get the exit_status
jedi4ever authored
27 p=sh.execute "grep dont /tmp/notexist"
28 puts "Exit Status:#{p.exit_status}"
29 puts "Command Executed:#{p.command}"
def7a17 @jamis make this place livable!
jamis authored
30 end
31 end
32
33 See Net::SSH::Shell for more documentation.
34
35 == REQUIREMENTS:
36
37 * net-ssh (version 2)
38
39 If you want to use any of the Rake tasks, you'll need:
40
41 * Echoe (for the Rakefile)
42
43 == INSTALL:
33896bd @mitchellh Update README, since the gem is now on rubygems
authored
44
45 This gem is available from RubyGems, so you can install it using the "gem" command:
def7a17 @jamis make this place livable!
jamis authored
46
a4ecce7 @jedi4ever how to build the gem locally
jedi4ever authored
47 * gem install net-ssh-shell
48
33896bd @mitchellh Update README, since the gem is now on rubygems
authored
49 If you'd like to build the gem for yourself from source:
a4ecce7 @jedi4ever how to build the gem locally
jedi4ever authored
50 * git clone http://github.com/jedi4ever/net-ssh-shell.git
51 * cd net-ssh-shell
52 * gem install echoe
53 * rake gem
54 * gem install pkg/net-ssh-shell-0.1.0.gem (might need sudo privileges)
def7a17 @jamis make this place livable!
jamis authored
55
56 == LICENSE:
57
58 (The MIT License)
59
60 Copyright (c) 2009 Jamis Buck <jamis@37signals.com>
61
62 Permission is hereby granted, free of charge, to any person obtaining
63 a copy of this software and associated documentation files (the
64 'Software'), to deal in the Software without restriction, including
65 without limitation the rights to use, copy, modify, merge, publish,
66 distribute, sublicense, and/or sell copies of the Software, and to
67 permit persons to whom the Software is furnished to do so, subject to
68 the following conditions:
69
70 The above copyright notice and this permission notice shall be
71 included in all copies or substantial portions of the Software.
72
73 THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
74 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
75 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
76 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
77 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
78 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
79 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Something went wrong with that request. Please try again.