read_file_chunk
Read an arbitrary set of lines from a file in ruby.
Basic Usage
host = Kanrisuru::Remote::Host.new(host: '127.0.1.1', username: 'ubuntu', keys: ['~/.ssh/id_rsa'])
result = host.read_file_chunk('/etc/crontab', 3, 5)
result.success?
true
result.to_a
[
[0] "# command to install the new version when you edit this file",
[1] "# and files in /etc/cron.d. These files also have username fields,",
[2] "# that none of the other crontabs do."
]
Parameters
Field | Type | Description |
---|---|---|
path |
string
|
Required file path to get output chunk from. |
start_line |
integer
|
Required line number to start reading from |
end_line |
integer
|
Required line number to stop reading from |
Result
Returns an array of lines starting from the Kth line in the file, and ending in the Jth line.
Exit Status
Code | Description |
---|---|
0 | Success |
1 | Failure |
Tested On
- Ubuntu, Debian, Centos, Fedora, Redhat, OpenSuse, SLES