简体   繁体   English

从新贵脚本中读取文件

[英]Read a file from upstart script

I need to read aa file from my upstart script in order to determine the environment. 我需要从我的新贵脚本中读取一个文件,以便确定环境。 The file which store the environment reside in /home/test/env. 存储环境的文件位于/ home / test / env中。

This env file content is, 该环境文件的内容是,

export environment=dev

How can i read this env file and get the value "dev" to a variable in the upstart script? 我如何读取此env文件,并在upstart脚本中将值“ dev”获取到变量?

Do you mean to "source" the content? 您是要“获取”内容吗?

# cat foo
bar=VALUE
# source foo
# echo $bar
VALUE

It 'source' the file as a shell script in the current script scope. 它将文件“源”为当前脚本作用域中的shell脚本。 You can use "." 您可以使用 ”。” in place of "source" (. foo) 代替“源”(.foo)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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