Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
ssh to execute remote ruby script
Blake Miller
5/15/2008 3:54:00 PM
I'm using 'net/ssh' to ssh into a OS X server and run a ruby script,
like this:
Net::SSH.start( "xxx.xxx.xxx", :username => 'xxx', :password => 'xxx'
) do | session |
shell = session.shell.open
shell.exec "ruby /usr/local/pgsql/share/migrate.rb
#{params['host']}"
end
The migrate.rb looks like this:
require 'rubygems'
...some ruby code
For some reason, the script fails to execute anything after the require
'rubygems' line. If I remove that line, the script will run, but
obviously I cannot use any gems, which I need.
If I ssh via terminal to the server, I can run the script fine with:
ruby /usr/local/pgsql/share/migrate.rb 1
I can't figure out why, when ssh'ing via the net/ssh package, the remote
script cannot include rubygems.
Any ideas?
--
Posted via
http://www.ruby-...
.
3 Answers
ara.t.howard
5/15/2008 4:02:00 PM
0
On May 15, 2008, at 9:53 AM, Blake Miller wrote:
>
> I can't figure out why, when ssh'ing via the net/ssh package, the
> remote
> script cannot include rubygems.
the remote machine has two rubys, one which has rubygems installed and
one without - when you ssh into a machine you may or may not have your
environment configured correctly and, thus, may or may not have your
'normal' PATH set. try your command with the full path to the ruby
you are expecting to use. note that any
system 'something'
may also fail if the PATH setting is indeed the cause.
this is a wild ass guess.
a @
http://codeforp...
--
we can deny everything, except that we have the possibility of being
better. simply reflect on that.
h.h. the 14th dalai lama
Chiyuan Zhang
5/15/2008 4:05:00 PM
0
Maybe some environment variables is not set properly when logged in as
non-interactive session? It seems interactive shell and non-interactive
ones do not run the same bunch of start up scripts. like ~/.profile,
~/.bashrc , etc.
On Thu, May 15, 2008 at 11:53 PM, Blake Miller <blakeage@hotmail.com> wrote:
> I'm using 'net/ssh' to ssh into a OS X server and run a ruby script,
> like this:
>
> Net::SSH.start( "xxx.xxx.xxx", :username => 'xxx', :password => 'xxx'
> ) do | session |
> shell = session.shell.open
> shell.exec "ruby /usr/local/pgsql/share/migrate.rb
> #{params['host']}"
> end
>
> The migrate.rb looks like this:
>
> require 'rubygems'
> ...some ruby code
>
> For some reason, the script fails to execute anything after the require
> 'rubygems' line. If I remove that line, the script will run, but
> obviously I cannot use any gems, which I need.
>
> If I ssh via terminal to the server, I can run the script fine with:
> ruby /usr/local/pgsql/share/migrate.rb 1
>
> I can't figure out why, when ssh'ing via the net/ssh package, the remote
> script cannot include rubygems.
>
> Any ideas?
> --
> Posted via
http://www.ruby-...
.
>
>
--
pluskid
Blake Miller
5/15/2008 4:19:00 PM
0
ara.t.howard wrote:
> try your command with the full path to the ruby you are expecting to use.
That worked...the new code uses the ruby in /usr/local/bin/ruby:
shell.exec "/usr/local/bin/ruby /usr/local/pgsql/share/migrate.rb
#{params['host']}"
--
Posted via
http://www.ruby-...
.
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
ssh to execute remote ruby script
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password