Sha256: 53f014db93f54707b72b129f7dc1a7c8af2bf263a76772de26dfb2d048573864

Contents?: true

Size: 1.19 KB

Versions: 3

Compression:

Stored size: 1.19 KB

Contents

module SeleniumGrid
  module AWS
    
    class RemoteCommand
      attr_accessor :options
      
      def initialize(command, options={})
        @command, @options = command, options
      end
      
      def execute
        puts full_command
        system full_command
        raise "Error with #{full_command}" if 0 != $?        
      end
      
      def full_command
        cmd = "#{ssh_command} " 
        cmd << "\"su -l #{options[:su]} -c " if options[:su]
        cmd << "'#{remote_command}'"
        cmd << '"' if options[:su]
        cmd
      end
      
      def ssh_command
        shell_command = [ "ssh" ]
        shell_command << "-i '#{options[:keypair]}'" if options[:keypair]
        shell_command << "root@#{options[:host]}"
        
        shell_command.join " "
      end

      def remote_command
        shell_command = []
        shell_command << "PATH=#{options[:path]}:${PATH}; export PATH;" if options[:path]
        shell_command << "DISPLAY=#{options[:display]}; export DISPLAY;" if options[:display]
        shell_command << "cd '#{options[:pwd]}';" if options[:pwd]
        shell_command << @command
        
        shell_command.join " "
      end
      
    end  

  end
end

Version data entries

3 entries across 3 versions & 3 rubygems

Version Path
selenium-rspec-dsl-1.0.2 vendor/selenium-grid-1.0.4/examples/ec2/lib/selenium_grid/aws/remote_command.rb
davidtrogers-selenium-grid-0.0.1 examples/ec2/lib/selenium_grid/aws/remote_command.rb
statt-0.0.1 lib/selenium-grid/examples/ec2/lib/selenium_grid/aws/remote_command.rb