繁体   English   中英

使用来自 sh 脚本文件的 erb 文件中的变量

[英]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.

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