environment-variables

How to assign and reference environment variables containing square brackets in Powershell

[亡魂溺海] 提交于 2020-01-23 12:27:46
问题 When the PSDrive is not specified, the following works: ${[foo]}="bar" echo ${[foo]} But the following does not work $env:${[foo]}="bar" At line:1 char:1 + $env:${[foo]}="bar" + ~~~~~ Variable reference is not valid. ':' was not followed by a valid variable name character. Consider using ${} to delimit the name. At line:1 char:6 + $env:${[foo]}="bar" + ~~~~~~~~~~~~~~ Unexpected token '${[foo]}="bar"' in expression or statement. + CategoryInfo : ParserError: (:) [],

How to use path of current conda environment's python as shebang for a script?

半世苍凉 提交于 2020-01-23 09:51:06
问题 Let's say you have 2 conda environments: py3_env and py3_clone_env If you have a script.py with the following structure: #![shebang] import sys def main(): print("hello world", file=sys.stdout) if __name__ == "__main__": main() Is it possible to have the shebang be a variable that is determined from the current conda environment? For example: From py3_env environment: #!~/anaconda/envs/py3_env/bin/python and from py3_clone_env environment: #!~/anaconda/envs/py3_clone_env/bin/python 回答1: I

Overriding configuration with environment variables in typesafe config

耗尽温柔 提交于 2020-01-23 04:53:19
问题 Using typesafe config, how do I override the reference configuration with an environment variable? For example, lets say I have the following configuration: foo: "bar" I want it to be overriden with the environment variable FOO if one exists. 回答1: If I correctly understood your question, the answer is here. You can do foo: "bar" foo: ${?FOO} 回答2: The official doc now describes it very clearly and supports multiple options for this. Here is a brief summary... Most common way is to use this

IntelliJ does not recognize PATH variable

我怕爱的太早我们不能终老 提交于 2020-01-22 17:24:29
问题 I recently tried to import an existing Gradle project, using the option "Open Project" in the startup window and the existing build.gradle file to automatically set-up the project. Right after I did this, an error message appeared in IntelliJ, saying: Could not fetch model of type 'BasicIdeaProject' using Gradle installation '/Users/myUser/Tools/gradle-1.3'. Build file '/Users/myUser/IdeaProjects/myProject/database/build.gradle' line: 20 A problem occurred evaluating project ':database'. A

Scala: Unable to set environment variable

百般思念 提交于 2020-01-21 15:19:38
问题 Friends, I'm trying to set the environment variable "asdf" in my Scala shell, as described here These are my commands: scala> import scala.sys.process.Process import scala.sys.process.Process scala> Process(Seq("bash", "-c", "echo $asdf"), None, "asdf" -> "Hello, world!").! Hello, world! res18: Int = 0 But when i try to read the environment variable back: scala> sys.env.get("asdf") res19: Option[String] = None The output says "None". How do i properly set my environment variable in the

Exporting JSON to environment variables

两盒软妹~` 提交于 2020-01-21 02:57:38
问题 If I have a JSON like this, { "hello1": "world1", "testk": "testv" } And I want to export each of these key-value pairs as environment variables, how to do it via shell script? So for example, when I write on the terminal, echo $hello1 , world1 should be printed and similarly for other key-value pairs? Note: The above JSON is present in a variable called $values and not in a file. I know it will be done via jq and written a shell script for this, but it doesn't work. for row in $(echo "$

Setting a system variable within a maven profile

时间秒杀一切 提交于 2020-01-21 01:05:20
问题 Is it possible within maven to set a system property that is attainable from within a java class. I have seen that this is possible (here) within the surefire plugin as follows; String param = System.getProperty("my_parameter1"); <configuration> <systemPropertyVariables> <my_property1>${my_property1}</my_property1> </systemPropertyVariables> </configuration> However I would like to get a handle on the environment I am working in, I am already passing prod or dev as a maven profile argument -

Setting a system variable within a maven profile

浪尽此生 提交于 2020-01-21 01:05:11
问题 Is it possible within maven to set a system property that is attainable from within a java class. I have seen that this is possible (here) within the surefire plugin as follows; String param = System.getProperty("my_parameter1"); <configuration> <systemPropertyVariables> <my_property1>${my_property1}</my_property1> </systemPropertyVariables> </configuration> However I would like to get a handle on the environment I am working in, I am already passing prod or dev as a maven profile argument -

Persisting an environment variable through Ruby

早过忘川 提交于 2020-01-19 05:04:45
问题 I am trying to set my DOS environment variable in Ruby, and have it persist after the script exits. For example, if I want a ruby script set_abc_env.rb to set environment variable 'ABC' to 'blah', I expect to run the following: C:> echo %ABC% C:> set_abc_env.rb C:> echo %ABC% blah How do I do this? 回答1: You can access environment variables via Ruby ENV object: i = ENV['ABC']; # nil ENV['ABC'] = '123'; i = ENV['ABC']; # '123' Bad news is, as MSDN says, a process can never directly change the

$ENV:USERNAME returns the machine name when SCCM runs a script as admin with a non-admin logged in

≡放荡痞女 提交于 2020-01-17 04:49:07
问题 I have a script that needs to run from Software Center when a non-admin is logged in. It needs to copy application data to $ENV:USERNAME\AppData\<dir>\* (among other things) and it needs to run as administrator to work properly. The problem that I've discovered is that when the script is run on a non-admin profile with admin privileges the environment variable $ENV:USERNAME returns the machine name rather than the actual logged in username. Is there a way around this? 回答1: You can either use