0
我試圖製作一個ruby腳本來附加AWS EC2中的EBS卷。我錯過了一些小細節,因爲我在附加音量時遇到錯誤。請參閱下面的錯誤:ec2-aws創建卷和附加捲腳本
#!/usr/bin/env ruby
require 'rubygems'
cmd = "ec2-create-volume --size 10 --region us-east-1 --availability-zone us-east-1a --type gp2"
system(cmd, :out => ['/tmp/volid', 'w'])
volid = `awk '{print $2}' /tmp/volid`
puts "#{volid}" -----> PUTS THE VARIABLE AS EXPECTED
cmd = "ec2-attach-volume #{volid} --instance i-2e69a1b5 --device /dev/xvdg"
system(cmd) ----> It shows ERROR -i instance/--instance is missing, somehow is putting the variable incorectly, it's like is not reading the command after the volid variable.
如果我宣佈了voldid =「卷-123」的腳本工作,但如果我把它從一個文件,如果其輸出顯示體積-123甚至沒有工作。
這很好,它的工作。謝謝你的提示。 –