How to use environment variable(string) in a .conf file - bash

I have a .conf file that has a label and variable that I'm trying to move to a .env file. How can I accomplish this?
This is what I have in my .conf file
[[inputs.snmp]] #Label
agents = ["1.1.1.1:111","2.2.2.2:111","2.3.3.3:111"] #Variable
version = 2 #Variable
I'm trying to have something like this in the .env file
VAR_FOR_CONF_FILE='[[inputs.snmp]]\n agents= ["1.1.1.1:111","2.2.2.2:111","2.3.3.3:111"]\n version=2'
I was hoping I could use $VAR_FOR_CONF_FILE in my .conf file instead of [[inputs.snmp]]agents = ["1.1.1.1:111","2.2.2.2:111","2.3.3.3:111"]
but I keep getting this error Error parsing data: line 7: invalid TOML syntax for $VAR_FOR_CONF_FILE (Im not sure if I'm getting this error because I have the syntax wrong in my .env file or I'm declaring $VAR_FOR_CONF_FILE incorrectly in my .conf file)
Am I doing it correctly (or is it even possible to do what I'm trying to accomplish)?
(Note: I'm trying to accomplish this so I can simply use $VAR_FOR_CONF_FILE instead of hard coding things in the .conf file)

I'm trying to use VAR_FOR_CONF_FILE in the .conf file
If the .conf file parsing program doesn't support variable substitution, there's no way around modifying the .conf file, but this can be automated:
sed -i "s/\<VAR_FOR_CONF_FILE\>/$VAR_FOR_CONF_FILE/" my.conf

Related

How do I connect .env file to config.yml?

I'm currently building a Shopify store and would like to use env variables in Themekit's config.yml file. What I'm confused about is how to connect the .env file to the yml file, since I don't think you can just require dotenv. I have my .env file, and the code below in the config.yml. Thanks!
password: ${DEV_PASSWD}
theme_id: ${DEV_THEMEID}
store: ${DEV_SHOP}
You can't include .env file inside a YAML one. However, you can interpolate variables into your config.yml file using the ${} notation.
To help you interpolate variables, there are special files that can be used to automatically to load environment variables for Theme Kit. The following table lists the file paths for each operating system:
macOs: ${HOME}/Library/Application Support/Shopify/Themekit/variables
Linux/BSD: ${XDG_CONFIG_HOME}/Shopify/Themekit/variables
Windows: %APPDATA%\Shopify\Themekit\variables
Even more, you can use the --vars flag in any command to provide a path to a file for loading variables. The variables file has the same format as most .env type files. But note, the .env file is not interpolated by YAML itself and it cannot be connected using standard YAML include directives. All magic is provided exclusively by shopify and its --vars flag.

Laravel - How to declare a file path constent in .env file?

In one of my Laravel based application, I want to include a JSON key file that is currently located in public/key/store.json
Now I want to write a constant in Laravel .env file so that I can access that file anytime I want. So, I write the following line of code:
KEY_FILE='/public/key/store.json'
But it show file path does not exist.
Can anyone tell me what's wrong in my declaration?
you should push your path in your app/config.php not in your .env

Changing configuration options for Marathon

I'd like to change set various configuration options for Marathon, and I'm unsure how to do this. For example, I'd like to add --event_subscriber http_callback to the launch command.
For each configuration you can create a file in the directory /etc/default/marathon where the filename is the name of the option and a single line in the file containing the value for that option.
Eg. Make a file /etc/default/marathon/event_subscriber that contains the line "http_callback"
This also works for mesos.
Actually the directory has to be /etc/marathon/conf. This is valid for 0.11.1.

JMeter: How to specify the users.csv file in the command line

When using JMeter from the command line, I get the following error in my log:
2014/08/05 14:29:43 ERROR - jmeter.config.CSVDataSet: java.io.FileNotFoundException:
/home/stew/YOU_FORGOT_TO_SPECIFY_USERS_CSV_FILE.csv (No such file or directory)
The user.csv file is in the same directory as the testplan.jmx file. Is there an option to specify the file in the command line?
Regards,
Wolf
If you use relative file name for path then it should work, as per reference documentation:
Filename Name of the file to be read. Relative file names are resolved with respect to the path of the active test plan. For distributed testing, the CSV file must be stored on the server host system in the correct relative directory to where the jmeter server is started.
For another solution, Have a look at :
http://jmeter.apache.org/usermanual/functions.html#__P
You use this function in CSV dataset :
${__P(resdir)}
and on command line:
-Jresdir=your path to csv file
I was using Jmeter to test load Moodle and used options -Jresdir and -Jusersfile options to pass usersfile name

File locations in shell script property files

I have a property looks like below in property file and the properties are ready by "sourcing" in shell script.
MW_INSTALLER_11.6="/ade_autofs/scratch/test/installer/wls_generic.jar"
During sourcing, observing the below error and the variable is not read.
Where all other properties are read perfectly fine.
./upgrade.properties: line 45: MW_INSTALLER_11.6=/ade_autofs/scratch/test/installer/wls_generic.jar: No such file or directory
The file mentioned above is present specified path. Observing same issue with or without double quotes.
What is the right way to add the file location in property file?
Code around above specified property in property files
POST_UPGRADE_ANT_OPTIONS=
MW_INSTALLER_11.6="/ade_autofs/scratch/test/installer/wls_generic.jar"
NO_OF_RELEASES_TO_UPGRADE=1
Code around sourcing property file in shell script, here $1 represents property file
echo "Reading properties file $1" | tee -a $LOG_DRIVER_FILE
. ./$1
UPGRADE_PROPERTIES_FILE=$1
thanks In Advance, soman
I found the issue. Issue is due to the variable name contains "." [dot]
after changing from MW_INSTALLER_11.6="/ade_autofs/scratch/test/installer/wls_generic.jar"
to
MW_INSTALLER_11_6="/ade_autofs/scratch/test/installer/wls_generic.jar"
It worked fine.
Regards.

Resources