Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ruby executing remote scripts in one line. (like installing rvm)

install rvm in one line example:

user$ bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)

Now, say I have a ruby scripts like this at http://blah.com/helloworld.rb

puts "what's ur name?"
name = gets.chomp
puts "hello world from web, #{name}"

I would like to achieve this it in my shell without creating a temp file in one line or even better one command.

wget http://blah.com/helloworld.rb; ruby helloworld.rb; rm helloworld.rb

I have tried this, but user prompt will be ignored because of earlier pipe.

curl -s http://blah.com/helloworld.rb | ruby

What's the correct way to executing a remote ruby script? Thanks!

like image 725
c2h2 Avatar asked Jul 06 '11 13:07

c2h2


1 Answers

Like this:

ruby < <(curl -s http://blah.com/helloworld.rb)

Ruby evaluates ruby code similarly to how bash evaluates shell code

like image 68
Björn Nilsson Avatar answered Nov 15 '22 06:11

Björn Nilsson