如何在控制台打印输出?
How to print the output on the console?
我试图在执行时在控制台上显示 "curl's" 输出。下面是我写的。它打印我在 puts
中为所有主机名声明的语句,这是按照设计的。
desc "check_app_version <environment> <project>", "checks the /dev/info page of the app"
def check_app_version(environment, project)
check_environment(environment)
machines = `knife node list`.split
machines.each do |hostname|
puts "checking the app-version for #{hostname}"
system("curl --silent -m 5 #{hostname}:8080/dev/info |grep 'Application\|Build'")
end
end
但是我没有看到下一行指示在我的服务器上执行 curl 的任何内容。
使用反引号符号 return 一个字符串,然后 return 到 puts
puts `curl --silent -m 5 #{hostname}:8080/dev/info |grep 'Application\|Build'`
puts `curl --silent -m 5 #{hostname}:8080/dev/info |grep 'Application\|Build'`
我试图在执行时在控制台上显示 "curl's" 输出。下面是我写的。它打印我在 puts
中为所有主机名声明的语句,这是按照设计的。
desc "check_app_version <environment> <project>", "checks the /dev/info page of the app"
def check_app_version(environment, project)
check_environment(environment)
machines = `knife node list`.split
machines.each do |hostname|
puts "checking the app-version for #{hostname}"
system("curl --silent -m 5 #{hostname}:8080/dev/info |grep 'Application\|Build'")
end
end
但是我没有看到下一行指示在我的服务器上执行 curl 的任何内容。
使用反引号符号 return 一个字符串,然后 return 到 puts
puts `curl --silent -m 5 #{hostname}:8080/dev/info |grep 'Application\|Build'`
puts `curl --silent -m 5 #{hostname}:8080/dev/info |grep 'Application\|Build'`