简体   繁体   中英

How to query a file name using URI ruby matchine platform_version and machine (x86_64

这无法正常工作,因为sed在客户端运行期间未被厨师识别,我不确定为什么..仍然存在。

def vbox_file shell_out("curl -sS http://download.virtualbox.org/virtualbox/5.1.26 | grep -i virtualbox | grep -i el#{platform_version} | grep -i `uname -m` | sed 's/^.*>\\([^<]*\\)<.*$/\\1/'").run_command.stdout end

If it is just failing because it can't find sed; then you probably just need to include the full path for sed on your system.

On my system it is located at "/bin/sed", but you can run the command "which sed" to find out where it is on your system.

Non-answer, don't do this in shell code. Use Ruby:

def vbox_file
  Chef::HTTP::Simple.new('http://download.virtualbox.org/').get('/virtualbox/5.1.26')[/href="(.*?el#{node['platform_version'][0]}.*?#{node['kernel']['machine']}.*?)", 1]
end

Or something like that, tweak the regex as needed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM