Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
ruby在一行中执行远程脚本。(如安装rvm)_Ruby_Linux_Bash_Shell - Fatal编程技术网

ruby在一行中执行远程脚本。(如安装rvm)

ruby在一行中执行远程脚本。(如安装rvm),ruby,linux,bash,shell,Ruby,Linux,Bash,Shell,在一条管线中安装rvm示例: user$ bash < <(curl -s https://rvm.beginrescueend.com/install/rvm) 我想在我的shell中实现这一点,而不需要在一行或更好的命令中创建临时文件 wget http://blah.com/helloworld.rb; ruby helloworld.rb; rm helloworld.rb 我已经尝试过了,但是由于前面的管道,用户提示将被忽略 curl -s http://blah.co

在一条管线中安装rvm示例:

user$ bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)
我想在我的shell中实现这一点,而不需要在一行或更好的命令中创建临时文件

wget http://blah.com/helloworld.rb; ruby helloworld.rb; rm helloworld.rb
我已经尝试过了,但是由于前面的管道,用户提示将被忽略

curl -s http://blah.com/helloworld.rb | ruby
执行远程ruby脚本的正确方法是什么?谢谢

像这样:

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

ruby<另一个基于Calibre安装的ruby选项,用于shell脚本:

ruby -e "require 'open-uri'; system open('http:// or local file').read"
Ruby脚本也是如此:

ruby -e "require 'open-uri'; eval open('http:// or local file').read"

已编辑:修复了缺少的引号和添加的Ruby脚本执行

在Ruby代码中,您必须重新打开stdin并将其绑定到控制终端设备
/dev/tty

rubyscript="$( cat <<-'EOF'
puts "what's ur name?"
name = gets.chomp
puts "hello world from web, #{name}"
EOF
)"

ruby <(echo '$stdin.reopen(File.open("/dev/tty", "r"))'; echo "$rubyscript")
rubyscript=“$(类别来自:


第一个
你是对的,我忘记了一个引号,并将其更改为使用ruby脚本。我将编辑它以修复它。谢谢
rubyscript="$( cat <<-'EOF'
puts "what's ur name?"
name = gets.chomp
puts "hello world from web, #{name}"
EOF
)"

ruby <(echo '$stdin.reopen(File.open("/dev/tty", "r"))'; echo "$rubyscript")
ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"