Solved

Expect for Ruby

Posted on 2008-10-17
3
1,204 Views
Last Modified: 2012-08-14
Hi everyone,

I've been assigned the task of automating one of our applications' intallation. One of the requirements is that this "automation script" should reside on a centralized location and should be able to remote connect to different boxes and run the installation package in each of them (via ssh for example). We want this script to work on UNIX.

I'm planning on learning Ruby to do this :-) The question I have is, do I need expect to automate the SSH connection so the user doesn't have to put in the usr and pwd? or ruby does that in the parameters of function that opens an ssh connection?

Many thanks in advance
0
Comment
Question by:aguiarrj
3 Comments
 
LVL 14

Accepted Solution

by:
wesgarrison earned 63 total points
ID: 22746996
This totally doesn't answer your question about rExpect, but have you looked at capistrano (www.capify.org)?

Simply put, Capistrano is a tool for automating tasks on one or more remote servers. It executes commands in parallel on all targeted machines, and provides a mechanism for rolling back changes across multiple machines. It is ideal for anyone doing any kind of system administration, either professionally or incidentally.
It's pretty handy for automation and remote deployments.  Basically, you supply commands and it'll wrap them in an SSH session and execute them on the remote server.

0
 
LVL 10

Assisted Solution

by:Andrew Doades
Andrew Doades earned 62 total points
ID: 22825519
see attached, you will need to run   gem install net-ssh

the below will login to the server and create myfile
You can alter this to ./myfile  to execute your file
require 'rubygems'

require 'net/ssh'
 
 

Net::SSH.start( 'server_name/ipaddress',

                :username=>'myuser',

                :password=>'mypass' ) do |session|
 

session.open_channel do |channel|

      channel.on_data do |ch, data|

        puts data

      end

      channel.exec 'touch myfile'

    end

    session.loop

end

Open in new window

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently rediscovered rails when I needed a holiday project and decided to build a management dashboard for the company where I work.  With it being a project done in my free time, I could focus my time on learning the basics rather than trying to…
Article by: narshlob
If you've ever programmed in Ruby and have come across either a proc or a lambda, you might have been wondering what the difference is between the two and when you would use one over the other. This article will try to explain the difference between…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

896 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now