Module Rye::Cmd
In: lib/rye/cmd.rb

Rye::Cmd

This class contains all of the shell command methods available to an instance of Rye::Box. For security and general safety, Rye only permits this whitelist of commands by default. However, you‘re free to add methods with mixins.

    require 'rye'
    module Rye::Box::Cmd
      def special(*args); run_command("/your/special/command", args); end
    end

    rbox = Rye::Box.new('somehost')
    rbox.special        # => "special on somehost"

Methods

ab   add_command   aptitude   awk   bash   bunzip2   bzip2   can   can?   can?   cat   chmod   chown   cmd?   cmds   command?   commands   configure   cp   curl   cvs   date   df   digest_md5   digest_sha1   digest_sha2   dir   dir_download   dir_upload   directory_download   directory_upload   dpkg   du   echo   env   file_append   file_download   file_exists?   file_modify   file_upload   file_verified?   file_write   getconf   git   grep   gunzip   gzip   hg   history   hostname   irb   ldconfig   ln   ls   make   mkdir   mkfs   mount   mv   perl   printenv   ps   pwd   python   rake   remove_command   ruby   rudy   rudy_ec2   rudy_s3   rudy_sdb   rye   sed   sh   siege   sleep   stella   stella   str_download   str_upload   str_upload   string_append   string_download   string_upload   su   svn   tail   tar   template_upload   template_write   test   touch   try   umount   uname   unxz   unzip   uptime   useradd   wc   wget   which   whoami   xz  

Public Class methods

A helper for adding a command to Rye::Cmd.

  • meth the method name
  • path (optional) filesystem path for the given method
  • hard_args (optional) hardcoded arguments which are prepended to the argument list every time the method is called

An optional block can be provided which will be called instead of calling a system command.

A helper for removing a command from Rye::Cmd.

  • meth the method name

Public Instance methods

When called without a block this will open an interactive shell session.

Returns an Array of system commands available over SSH

cmd?(meth)

Alias for can?

cmds()

Alias for can

command?(meth)

Alias for can?

commands()

Alias for can

  • files An Array of file paths

Returns an Array of MD5 digests for each of the given files

  • files An Array of file paths

Returns an Array of SH1 digests for each of the given files

  • files An Array of file paths

Returns an Array of SH2 digests for each of the given files

Same as file_download except directories are processed recursively. If any supplied paths are directories you need to use this method and not file_download.

Same as file_upload except directories are processed recursively. If any supplied paths are directories you need to use this method and not file_upload.

directory_download(*paths)

Alias for dir_download

directory_upload(*paths)

Alias for dir_upload

Append newcontent to remote filepath. If the file doesn‘t exist it will be created. If backup is specified, filepath will be copied to +filepath-previous+ before appending.

NOTE: Not recommended for large files. It downloads the contents.

Transfer files from a machine via Net::SCP.

  • paths is an Array of files to download. The last element must be the

local directory to download to. If downloading a single file the last element can be a file path. The target can also be a StringIO object. The target directory will be created if it does not exist, but only when multiple files are being transferred. This method will fail early if there are obvious problems with the input parameters. An exception is raised and no files are transferred. Return nil or a StringIO object, if specified as the target.

NOTE: Changes to current working directory with cd or +[]+ are ignored.

Does path from the current working directory?

Transfer files to a machine via Net::SCP.

  • paths is an Array of files to upload. The last element is the

directory to upload to. If uploading a single file, the last element can be a file path. The list of files can also include StringIO objects. The target directory will be created if it does not exist, but only when multiple files are being transferred. This method will fail early if there are obvious problems with the input parameters. An exception is raised and no files are transferred. Always return nil.

NOTE: Changes to current working directory with cd or +[]+ are ignored.

Does the calculated digest of path match the known expected_digest? This is useful for verifying downloaded files. digest_type must be one of: :md5, :sha1, :sha2

Write newcontent to remote filepath. If the file exists it will be overwritten. If backup is specified, filepath will be copied to +filepath-previous+ before appending.

When called without a block this will open an interactive shell session.

def kill(*args) run_command(‘kill’, args) end

When called without a block this will open an interactive shell session.

str_download(*paths)

Alias for string_download

str_upload(str, remote_path)

Alias for string_upload

str_upload(str, remote_path)

Alias for string_upload

Shorthand for +file_append(‘remote/path’, StringIO.new(‘file content’))+

Appends the content of the String str to remote_path. Returns nil

Shorthand for +file_download(‘remote/path’).string+

Returns a String containing the content of all remote paths.

Shorthand for +file_upload(StringIO.new(‘file content’), ‘remote/path’)+

Uploads the content of the String str to remote_path. Returns nil

Parse a template and upload that as a file to remote_path.

 NOTE: See Rye::Box for the implementation of cd

def cd(*args) run_command(‘cd’, args) end def rm(*args) run_command(‘rm’, args) end

[Validate]