gpt4 book ai didi

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

转载 作者:IT王子 更新时间:2023-10-29 00:48:02 25 4
gpt4 key购买 nike

在一行示例中安装 rvm:

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

现在,假设我在 http://blah.com/helloworld.rb 有一个这样的 ruby​​ 脚本

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

我想在我的 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 评估 ruby​​ 代码的方式类似于 bash 评估 shell 代码的方式

关于ruby 在一行中执行远程脚本。 (比如安装 rvm),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6597022/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com