[英]Use the variables in erb file from sh script file
我有一個腳本名稱first.sh ,其中我調用了幾個變量,如下所示:
#!/bin/bash
index1_0="a_b_c"
index2_0="b_c_d"
index3_0="c_d_e"
first.sh的腳本路徑是goal/first.sh 。我正在嘗試在另一個second.erb文件中使用上面在 first.sh 中調用的變量,如下所示:
% H = Hash["a" => "@index1_0",
% "b" => "@index2_0",
% "d" => "@index3_0",]
我需要在second.erb文件中使用first.sh腳本文件中聲明的變量,但沒有得到確切的 output。 有人可以幫忙嗎?
你需要
<%= ENV['index1_0'] %>
訪問需要從first.sh
導出的環境變量的值,例如
export index1_0="a_b_c"
並獲取它
source first.sh
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.