How to set environment setting? - byteman

https://downloads.jboss.org/byteman/4.0.20/byteman-programmers-guide.html#environment-settings
enter image description here
how to set "org.jboss.byteman.compileToBytecode" property?
this document doesn't give an example.
I try to set environment proproty as follow:
export org.jboss.byteman.dump.generated.classes=1
but get an issue:
-bash: export: `org.jboss.byteman.dump.generated.classes=1': not a valid identifier

This is a JVM property. You can set it this way:
java -Dorg.jboss.byteman.dump.generated.classes=1 -javaagent:$BYTEMAN_HOME/lib/byteman.jar=script:appmain.btm AppMain foo bar baz

Related

Golang use bash environment variables in Buffalo database.yml

I'm new to Go and Buffalo, and am attempting use my bash environment variables in my database.yaml
I attempted to do the following in my database.yaml, but it fails to interpret the value of my bash environment var localUser
user: ${localUser}
I set the localUser with the following bash
export localUser="username"
echo $localUser
username
Thanks for any help!!
Buffalo Pop's configuration, database.yml, supports the following syntax.
production:
host: "localhost"
user: {{ envOr "localUser" "defaultuser" }}
test:
dialect: "mysql"
url: {{ envOr "TEST_DATABASE_URL" "mysql://user:pass#(localhost:3306)/test" }}
The key is the envOr directive.
As you can imagine, the production.user will be set as the value from the environment variable localUser if the value exists, but it will fall back to its default value "defaultuser" if there is no environment variable.
With this syntax, you can configure environment-specific values dynamically.
This is good for many situations such as container images that could be used in multiple different configurations. You can distribute (or publish) your application "image" with the default value, then you can run your "container" with specific environmental variables with the real values.

Terraform to read variables from environment

I have written a terraform configuration with variable definition like:
variable "GOOGLE_CLOUD_REGION" {
type = string
}
When I run terraform plan I am asked to fill in this variable even though this variable is set within my environment.
Is there a way to tell terraform to work with current env vars? Or do I have to export them and pass them somehow manually one-by-one?
You can define the environment variable TF_VAR_GOOGLE_CLOUD_REGION to set that variable.
If you are using bash, it might look like this:
export TF_VAR_GOOGLE_CLOUD_REGION="$GOOGLE_CLOUD_REGION"
terraform apply ...
From Environment Variables under Configuration Language: Input Variables.
As a fallback for the other ways of defining variables, Terraform searches the environment of its own process for environment variables named TF_VAR_ followed by the name of a declared variable.
This can be useful when running Terraform in automation, or when running a sequence of Terraform commands in succession with the same variables. For example, at a bash prompt on a Unix system:
$ export TF_VAR_image_id=ami-abc123
$ terraform plan
...
You can create a file that ends with .tfvars or .tfvars.json and then when you run a plan you specify that file:
terraform apply -var-file="example.tfvars"
If you name the file terraform.tfvars or terraform.tfvars.json or have a file with names ending in .auto.tfvars or .auto.tfvars.json
then Terraform automatically loads the variable definition file and you don't have to manually specify it when you run a plan.
An example of what the terraform.tfvars file will look like:
first_env_var = "environment_variable_one"
second_env_var = "environment_variable_two"
An example of what the terraform.tfvars.json file will look like:
{
"image_id": "ami-abc123",
"availability_zone_names": ["us-west-1a", "us-west-1c"]
}
I would approach this by creating a variables.tf file, within the project directory. with the required variable block you can specify a default:
variable "GOOGLE_CLOUD_REGION" {
type = string
default = "us-west1"
}
this will then be used as the default value during each run, and you will not be prompted.

How do I specify the type of global variable in sorbet?

I have a global variable that is defined like this:
# -- in rollout_setup.rb
$rollout = Rollout.new(::CachedRolloutStore.new)
T.reveal_type($rollout) # got Rollout
# -- in foo.rb
T.reveal_type($rollout) # got T.untyped
Within the file, the type of $rollout is inferred correctly. However, it is inferred as T.untyped anywhere else that use the variable. I've tried to use T.let but it doesn't work.

Export: '0.0' : not a valid identifier in Bash

I am fairly new to Bash scripting and am trying to set environment and libraries to use and then build a particular script. Here is the Bash script I wrote:
#! /bin/bash
export DISPLAY :0.0
#setenv LD_LIBRARY_PATH /usr/local/szip2.1/lib:${LD_LIBRARY_PATH}
# above line should be equivalent to
export LD_LIBRARY_PATH "/usr/lib64:/usr/lib:$LD_LIBRARY_PATH"
module load Szip/2.1-gmpolf-2015
module load cuda/6.5
#while ( 1 )
cd /home/sbansal6/misr-stereo-2013.11.24
/home/sbansal6/misr-stereo-2013.11.24/bin/misr-stereo /home/sbansal6/ellipsoids/0034007 AN AA
#end
And here is what I get as the error:
[sbansal6#cg-gpu01 STEREO]$ ./mstdrv.csh
./mstdrv.csh: line 3: export: `:0.0': not a valid identifier
./mstdrv.sh: line 6: export: `/usr/lib64:/usr/lib:/sw/cuda/6.5/lib64:/sw/EasyBuild/software/Szip/2.1-gmpolf-2015/lib:/sw/EasyBuild/software/ScaLAPACK/2.0.2-gmpich-2015-OpenBLAS-0.2.14-LAPACK-3.5.0/lib:/sw/EasyBuild/software/FFTW/3.3.4-gmpich-2015/lib:/sw/EasyBuild/software/OpenBLAS/0.2.14-GCC-4.9.2-binutils-2.25-LAPACK-3.5.0/lib:/sw/EasyBuild/software/MPICH/3.1.4-GCC-4.9.2-binutils-2.25/lib:/sw/EasyBuild/software/GCC/4.9.2-binutils-2.25/lib/gcc/x86_64-unknown-linux-gnu/4.9.2:/sw/EasyBuild/software/GCC/4.9.2-binutils-2.25/lib64:/sw/EasyBuild/software/GCC/4.9.2-binutils-2.25/lib:/sw/binutils-2.25/lib': not a valid identifier
/home/sbansa16/misr-stereo-2013.11.24/bin/misr-stereo:error while loading shared libraries: libglut.so.3: cannot open shared object file: No such file or directory
I am basically trying to add the libraries from Szip and Cuda in my environment and then build a C++ program which is at the path I wrote later. I do understand that the last error that I got which said error while loading shared libraries: libglut.so.3 is because I don't have that library in my libraries.
I am sorry if this question is trivial. I appreciate any help. Thanks in advance.
UPDATE:
I have also tried using setenv from csh but it is still not working.
Bash syntax for setting an environment variable would be:
export NAME=value
or
NAME=value
export NAME

Why is LUA_PATH containing a bang (!) mangled on Windows?

I have a file main.lua:
require("hello")
and a file hello.lua in the directory foo bar! baz (with !) in it:
module(...,package.seeall)
print("hello from hello.lua")
when I set (on Windows) the environment variable LUA_PATH to the directory:
set LUA_PATH="C:\Programme\Lua\5.1\foo bar! baz\?.lua"
I get a strange error:
C:\Programme\Lua\5.1>lua main.lua
lua: main.lua:4: module 'hello' not found:
no field package.preload['hello']
no file '"C:\Programme\Lua\5.1\foo barC:\Programme\Lua\5.1 baz\hello.lua
"'
no file '.\hello.dll'
no file '.\hello51.dll'
no file 'C:\Programme\Lua\5.1\hello.dll'
no file 'C:\Programme\Lua\5.1\hello51.dll'
no file 'C:\Programme\Lua\5.1\clibs\hello.dll'
no file 'C:\Programme\Lua\5.1\clibs\hello51.dll'
no file 'C:\Programme\Lua\5.1\loadall.dll'
no file 'C:\Programme\Lua\5.1\clibs\loadall.dll'
stack traceback:
[C]: in function 'require'
main.lua:4: in main chunk
[C]: ?
See the very strange path C:\Programme\Lua\5.1\foo barC:\Programme\Lua\5.1 baz\hello.lua? What is so special about the exclamation mark (bang)? How to get that right in windows? On Mac this seems to be working fine.
"This substitution only happens the first time Lua sets the path
(either from LUA_PATH or from the default from luaconf). If you
set the path by other means, you can avoid the problem."
More info and potential alternatives: http://lua-users.org/lists/lua-l/2012-08/msg00052.html
The explanation is correct (it's documented behavior on Windows), but I can also offer a possible solution (or rather a workaround): since only the first exclamation mark is going to be replaced, instead of using set LUA_PATH="C:\Programme\Lua\5.1\foo bar! baz\?.lua", use:
set LUA_PATH="!\foo bar! baz\?.lua"

Resources