Clear all property values in a properties file - shell

I have a properties file which contains several name=value pairs. This properties file contains several secrets in value. My requirement is to delete the property value after reading the values using a shell script. The property file will also contain comments.
Properties file:
#docker image key
name=secret_value
#username
abc=bcd
#password
def=efg
The shell script should delete all values after reading the properties file like:
New Properties file :
#docker image key
name=
#username
abc=
#password
def=
How to achieve this?

In the script, after the properties file is read, add the below command:
sed -i 's/\=.*/=/' property_file_name

Related

how provide value from text file to yaml file?

I am using YAML file to read/write data from the s3 bucket, i have mentioned the AWS access key and secret key inside the YAML file itself.
but now I want to put aws_secret_key in another txt file, and read the secret key from the text file.
How can we configure the YAML file to read the aws_secret_ key from another file?
Please help me.
Thanks & Regards,
Prasad

How to read data from csv file in jmeter whose location is not fixed and might change in the future

I have a CSV File whose location is going to change later. Using Jmeter how can I still read the file even if the location change?
You can set the location of the CSV file as a JMeter property and pass it through the command line or through user.properties file
Set the file name with a property in the CSV Data Set Config element
${__P(full-path-to-file,/Users/hansi/Documents/test-data/test-data-users.csv)}
Note: A default value /Users/hansi/Documents/test-data/test-data-users.csv is set in the above screenshot.
2.Define the value
2.1 In user.properties file
full-path-to-file=/Users/hansi/Documents/test-data/test-data-users.csv
or
2.2 Set the property when JMeter test is executed from commandline
./jmeter.sh -n -t test-plan.jmx -Jfull-path-to="/Users/hansi/Documents/test-data/test-data-users.csv"
If the CSV file is going to change location then you could store the test plan which is using the file alongside it. This would maintain the context of the test plan if the CSV itself is going to be moving by storing them together. In JMeter relative file names are resolved with respect to the path of the active test plan (based on the official documentation), allowing you to specify only the name of the file in the CSV Data Set Config Filename property.

How to save a filename in a variable in Nifi?

I'm new to Nifi and I'm trying to get a file name and save this filename in a variable to be used later on in the process.
Basically I have a file(data_yyyyMMdd.tar.gz) which contains 2 .txt files(1.txt and 2.txt), and before to unpack this file, I want to save it's name to a variable and then, use this variable to add content to the unpacked files.
content of the files(originally) :
1.txt
id|name
1|apple
2|orange
content of the files after be updated with the filename
id|name|filename
1|apple|data_yyyyMMdd.tar.gz
2|orange|data_yyyyMMdd.tar.gz
I managed to unpack to file successfully, but, I'm not being able to save the .tar.gz filename in a variable and add it's value to the content of each file.
Could you guys help me?
Depending on what processor you used to get the tar.gz file, you likely already have a FlowFile attribute called filename set to the name of the tar.gz file. After unpacking you may find that the filename attribute is overwritten (not sure though), so before unpacking, copy the filename attribute into some other attribute using UpdateAttribute. For example you can add a property in UpdateAttribute named original.filename and set its value to ${filename}.
After unpacking you can use UpdateRecord to add the original filename as a field in each record, I think by setting the Replacement Value Strategy to Literal Value and adding a property /filename set to ${original.filename}. I haven't tried this so I don't know if these are exactly the right settings, but the approach should work.

Parametrize source folder directory or file path in JMeter

Is there any way to parameterize the CSV data file path or source directory path in JMeter?
There are at least 2 possibilities:
Via User Defined Variables like:
and then referring the variable in the CSV Data Set Config
Or via __P() function like:
the property value can be passed via -J command line argument or put into the user.properties file. See Overriding Properties Via The Command Line for more information.

How to handle 'display name' for add_object_type?

I am using Sphinx's add_object_type to create a custom object confval for configuration file values:
add_object_type('confval', 'confval', objname='configuration value', indextemplate='pair: %s; configuration value')`
However I have multiple configuration files and they could have the same value.
Consider:
..confval: filepath
Description filepath in configuration file foo.cfg
And
..confval: filepath
Description filepath in configuration file bar.cfg
I now have two filepath values. I could make them unique by changing their names to foo-filename and bar-filename but that changes the text that is presented to the user.
How can I generate unique index names for the values while maintaining the text that the user sees?
My current idea is to add an index option:
..confval: filepath
:index: foo-filepath
Description filepath in configuration file foo.cfg
But that would require creating a directive class. Can I do something with add_object_type?

Resources