Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > problems with rake and sh

Reply
Thread Tools

problems with rake and sh

 
 
Dave Foo
Guest
Posts: n/a
 
      01-27-2009
Hi,

I am using ssh to login to my Amazon EC2 server, and using a rake task
to automate some activities on the machine. Every time I login, it is a
new machine, so I have no host keys from the machine and SSH connections
pass back the warning that a new key was added to my local known hosts
file.

When I connect via the shell without using ruby, my command works great
with no errors. Inside my rake task, using ruby, I am almost always
having the rake task blow out with an error. How can I construct my ruby
to shell out without choking on this ssh issue???

eg command:

sh "ssh -i /home/foo/.ssh/id_rsa-bs-keypair
root@#{@instance[0][:dns_name]} 'mkdir /mnt/data_store && mount
/dev/sdf /mnt/data_store'"

This is usually resulting in something like:

ssh: connect to host ec2-72-44-38-77.compute-1.amazonaws.com port 22:
Connection refused
rake aborted!

Any one know of how I can get this small snippet to work in a ruby
task???

Thanks
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
 
Roger Pack
Guest
Posts: n/a
 
      01-28-2009

> Any one know of how I can get this small snippet to work in a ruby
> task???


maybe run it within bash or sh -c or so... [?]
-=r
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
 
Dave Foo
Guest
Posts: n/a
 
      01-28-2009
Roger Pack wrote:
>
>> Any one know of how I can get this small snippet to work in a ruby
>> task???

>
> maybe run it within bash or sh -c or so... [?]
> -=r


It does run fine in bash... the whole point for me is to use Ruby inside
a rake task to do my work... and the one thing I cannot figure out is
how to get the ssh connection to work.

If I connect once and simply exit... and then connect again, in the same
script.. with the same server instance, every further call that shells
out works fine. It is only a problem getting the initial shell
connection to work. I am sure there is a config change I can make to
solve this, but so far, my only work-around has been the silly "connect
first in a loop"...

Thanks

--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
Jarmo Pertman
Guest
Posts: n/a
 
      01-31-2009
Maybe Net::SSH could help you: http://net-ssh.rubyforge.org/

Jarmo

Dave Foo wrote:
> It does run fine in bash... the whole point for me is to use Ruby inside
> a rake task to do my work... and the one thing I cannot figure out is
> how to get the ssh connection to work.
> ...
> Thanks


--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Testing Rake tasks with RSpec... and Rake John Feminella Ruby 0 04-25-2010 06:40 PM
rake published rdoc version and arity of Rake::Task#execute - wrongnumber of arguments (0 for 1) James Mead Ruby 0 01-15-2008 05:42 PM
Rake TestTask running its block anytime rake is invoked Adam Anderson Ruby 1 09-19-2007 08:40 AM
Rake and rake aborted! Rake aborted! undefined method `gem' for main:Object peppermonkey Ruby 1 02-10-2007 04:43 AM
Rake 0.7.0 breaks "rake engine_migrate"? Joe Van Dyk Ruby 2 01-31-2006 12:11 AM



Advertisments