我必须在不同的Windows机器上设置环境变量,但我不想通过访问"我的电脑"的属性屏幕来手动更改它们
我想从命令行使用批处理文件.据我所知,使用set只会更改我将在命令窗口中调用的进程的变量.
我想明确地设置它,所以稍后,当运行一个新进程时,它将使用我设置的那些新设置.有没有办法从命令行执行此操作?
我想更改这个Makefile:
SHELL := /bin/bash
PATH := node_modules/.bin:$(PATH)
boot:
@supervisor \
--harmony \
--watch etc,lib \
--extensions js,json \
--no-restart-on error \
lib
test:
NODE_ENV=test mocha \
--harmony \
--reporter spec \
test
clean:
@rm -rf node_modules
.PHONY: test clean
Run Code Online (Sandbox Code Playgroud)
至:
SHELL := /bin/bash
PATH := node_modules/.bin:$(PATH)
boot:
@supervisor \
--harmony \
--watch etc,lib \
--extensions js,json \
--no-restart-on error \
lib
test: NODE_ENV=test
test:
mocha \
--harmony \
--reporter spec \
test
clean:
@rm -rf node_modules
.PHONY: test clean
Run Code Online (Sandbox Code Playgroud)
不幸的是,第二个不起作用(节点进程仍以默认值运行) …
如何在应用程序上下文中读取系统环境变量?
我想要的东西:
<util:properties id="dbProperties"
location="classpath:config_DEV/db.properties" />
Run Code Online (Sandbox Code Playgroud)
要么
<util:properties id="dbProperties"
location="classpath:config_QA/db.properties" />
Run Code Online (Sandbox Code Playgroud)
取决于环境.
我的应用程序上下文中可以有这样的东西吗?
<util:properties id="dbProperties"
location="classpath:config_${systemProperties.env}/db.properties" />
Run Code Online (Sandbox Code Playgroud)
其中实际的val是根据SYSTEM ENVIRONMENT VARIABLE设置的
我正在使用Spring 3.0
在bash上的Linux(Ubuntu 11.04)上,是否可以临时设置一个环境变量,该变量在脚本持续时间内只与普通变量不同?例如,在shell脚本中,通过临时将HOME设置为当前工作目录中的文件夹,然后启动应用程序,使应用程序保存到HOME便携式.
我使用的是node.js + express.js + everyauth.js.我已将所有的Everyauth逻辑移动到模块文件中
var login = require('./lib/everyauthLogin');
Run Code Online (Sandbox Code Playgroud)
在这里我加载我的oAuth配置文件与密钥/秘密组合:
var conf = require('./conf');
.....
twitter: {
consumerKey: 'ABC',
consumerSecret: '123'
}
Run Code Online (Sandbox Code Playgroud)
这些代码对于不同的环境是不同的 - 开发/登台/生产,因为回调是针对不同的URL.
曲.如何在环境配置中设置这些以过滤所有模块,还是可以将路径直接传递到模块中?
在env中设置:
app.configure('development', function(){
app.set('configPath', './confLocal');
});
app.configure('production', function(){
app.set('configPath', './confProduction');
});
var conf = require(app.get('configPath'));
Run Code Online (Sandbox Code Playgroud)
通过
app.configure('production', function(){
var login = require('./lib/everyauthLogin', {configPath: './confProduction'});
});
Run Code Online (Sandbox Code Playgroud)
?希望有道理
Python的标准库包含用于配置文件解析(configparser),环境变量读取(os.environ)和命令行参数解析(argparse)的模块.我想写一个程序来完成所有这些,还有:
有一系列选项值:
允许在命令行上指定的一个或多个配置文件位置,例如--config-file foo.conf,并读取(通常配置文件的替代或补充).这仍然必须遵守上述级联.
允许在一个位置使用选项定义来确定配置文件和命令行的解析行为.
将解析的选项统一到一个选项值集合中,以便程序的其余部分可以访问,而无需关心它们来自何处.
我需要的一切显然都在Python标准库中,但它们并不能顺利地协同工作.
如何以最小的Python标准库偏差实现这一目标?
python environment-variables configuration-files command-line-arguments
我想知道如何在命令提示符下显示Program Files(x86)的位置.我正在使用Windows 7 64位.
我试过了:
echo %programfiles(x86)%并且echo %programfiles%,
两者都只显示C:\Program Files
当我手工检查注册表,
HKLM /软件/微软/窗/ CURRENTVERSION,
该programfilesdir点C:\Program Files与
HKLM /软件/ WOW64 /微软/的Winodws/CURRENTVERSION,
该programfilesdir点C:\Program Files (x86).
但是,为什么我总是用C:\ Program Files?
我知道如何在我的/ etc/profile和我的环境变量中设置它.
但是如果我想在脚本中设置它呢?是导入os,sys?我该怎么做?
我是第一次尝试安装Python.我从Python网站下载了以下安装程序: Python 2.7.1 Windows Installer(Windows二进制文件 - 不包括源代码).然后我运行了安装程序,选择了"所有用户",一切都很好.我将Python安装到默认位置:
C:\Python27
Run Code Online (Sandbox Code Playgroud)
其次,要测试的Python被正确安装,我浏览到我的Python目录,并运行在Windows中的"蟒蛇"命令命令提示符.它返回以下错误:
ImportError:没有名为site的模块
当我做'python -v'时,我得到以下内容:
#installing zipimport hook
import zipimport # builtin
#ImportError: No module named site#installed zipimport hook #clear builtin ._
#clear sys.path#clear sys.argv
#clear sys.ps1#clear sys.ps2
#clear sys.exitfunc#clear sys.exc_type
#clear sys.exc_value#clear sys.exc_traceback
#clear sys.last_type#clear sys.last_value
#clear sys.last_traceback#clear sys.path_hooks
#clear sys.path_importer_cache#clear sys.meta_path
#clear sys.flags#clear sys.float_info
#restore sys.stdin#恢复sys.stdout
#restore sys.stderr#cleanup main
#cleanup[1] zipimport#cleanup[1] signal
#cleanup[1 …
从Dockerfile中未声明的docker容器中获取环境变量的最简单方法是什么?
例如,通过某个docker exec container /bin/bash会话设置的环境变量?
我能做到docker exec container env | grep ENV_VAR,但我更喜欢只返回价值的东西.
我尝试过使用docker exec container echo "$ENV_VAR",但替换似乎发生在容器之外,所以我没有从容器中获取env var,而是从我自己的计算机获取env var.
谢谢.