I'm trying to use IIB override command with kafka node to override the bootstrap value list but the result of this command is always the first value of the list only.
I'm using the command as below:
mqsiapplybaroverride -b test1.bar -k "kafkaApp" -m "KafkaConsumer#bootstrapServers=x,y,z"
and the result from this command is always as below:
<ConfigurableProperty override="x" uri="KafkaConsumer#bootstrapServers"/>
It is taking the first value only of the list which is "x" here and truncating the rest of list after the comma.
Could anyone please let me know how to execute the command so that it takes the whole bootstrap list not only the first value ?
The -m flag does not work if the property value has a comma in it.
Write your overrides into a file and use the -p flag:
# File: test1.overrides
KafkaConsumer#bootstrapServers=x,y,z
Then invoke it like this:
mqsiapplybaroverride -b test1.bar -k kafkaApp -p test1.overrides
Related
I want to use bash getops to pass a parameter. If the parameter has a value use the ${OPTARG}. If it does not have one default to something else.
Examples:
- run with no -d, debug=0, and verbose_level=""
`./my_script.sh`
- run with -d only, debug=1, and verbose_level="v"
`./my_script.sh -d`
- run with no -d vvvv, debug=1, and verbose_level="vvvv"
`./my_script.sh -d vvvv`
I am not sure this is possible, as printing the case value "${opts}" with d:, and using -d by itself shows no values.
Is it possible to accomplish this?
I would like to pass to a given Ruby script, a file as parameter. This file contains just a number (ID).
The command to run the Ruby scripts looks something like:
test export 123456 -o ./path/to/export -x
The number 123456 rappresents the parameter that i want to pass via txt/dat file from GitLab.
I tried:
test export "$(< /home/file.dat)" -o ./path/to/export -x
And also:
test export "`cat file.dat`" -o ./path/to/export -x
But i always get the same error:
cat: file.dat: No such file or directory
The very interesting point is that if i run cat before the other command, the content of the file is there (so the file is found). If i run it "nested" inside the Ruby command, it won't be found.
Any ideas how can i solve this?
Thank you very much
I'm not sure if this is what you're looking for, but you could pass the name of the file via command line and read the content of the file within the ruby script:
id = nil
# ARGV holds all the parameters passed to the script
File.readlines(ARGV[0]).each do |line|
id = line # id here will be set to the value contained in the file you passed a parameter
end
I am trying to get the return Boolean value of the command: sysctl debug.lowpri_throttle_enabled, in a shell script (run with zsh).
This command is for knowing whether macOS enables the limit of speed of low-order tasks (i.e. time machine).
Here is the script I have done now:
value=$(sysctl debug.lowpri_throttle_enabled)
echo $value
The output I got is:
>>>debug.lowpri_throttle_enabled: 0
But I just want 0/1 as output, how can I just get the boolean value but not the whole string? Thanks.
I have found the solution. Reference : https://ss64.com/osx/sysctl.html
With adding -n as option, it will only return the value.
e.g.
>>>sysctl -n debug.lowpri_throttle_enabled
0
>>>sudo sysctl debug.lowpri_throttle_enabled=1
>>>sysctl -n debug.lowpri_throttle_enabled
1
According to the description, -n is for:
Show only variable values, not their names. This option is useful for setting shell variables.
And -b is for:
Force the value of the variable(s) to be output in raw, binary format. No names are printed and no terminating newlines are output.
But I don't know why only -n works in this case, -b doesn't.
I'm trying to append command line arguments to the standard script generated by sbt-native-packager but I can't figure out how to get the behaviour I want having read the docs.
Basically, I want to add something like this to my applicaiton.ini file.
-server
-J-Xms256m
-J-Xmx512m
-Dcom.sun.management.jmxremote=true
-Dcom.sun.management.jmxremote.port=1616
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
-Djava.rmi.server.hostname=$(getIpAddress)
All good so far but you may have noticed the $(getIpAddress). I want a value assigned here from a function that'll run on the host machine.
I can add the function getIpAddress to the script template with:
bashScriptExtraDefines ++=
IO.readLines(sourceDirectory.value / "scripts" / "find_ip.sh")
So the content gets appended to the runner script like this:
getIpAddress() {
echo 10.0.1.23 . # impl snipped for brevity
}
# java_cmd is overrode in process_args when -java-home is used
declare java_cmd=$(get_java_cmd)
# if configuration files exist, prepend their contents to $# so it can be processed by this runner
[[ -f "$script_conf_file" ]] && set -- $(loadConfigFile "$script_conf_file") "$#"
run "$#"
The set -- $(loadConfigFile "$script_conf_file") "$#" bit is prepending the java command with the content of my application.ini but it wont evaluate the function.
So, I get that the contents is prepended to the java command with -- but I don't know if I can get it to evaluate $(getIpAddress). When I execute the script, the output looks like this, showing it's not calling the function. I need the resolved value here.
$ ./my-app -v
# Executing command line:
/Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/Contents/Home/bin/java
-Xms256m
-Xmx512m
-Dcom.sun.management.jmxremote=true
-Dcom.sun.management.jmxremote.port=1616
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
-Djava.rmi.server.hostname=$(getIpAddress)
-cp
/Users/toby/my-app.jar
my.app.Main
-serve
Is there alternative ways to achieve the same thing -- adding more "dynamic" values to the generated script? Have I got my bash commands wrong? :'(
Arguments in the INI file won't get expanded. You could add it to the script instead:
bashScriptExtraDefines += """addJava "-Djava.rmi.server.hostname=$(getIpAddress)""""
I have a bash script that take advantage of a local toolbox to perform an operation
my question is fairly simple
I have multiple files that are the same quantities but different time steps i would like to first untar them all, and then use the toolbox to perform some manipulation but i am not sure if i am on the right track.
=============================================
The file is as follows
INPUTS
fname = a very large number or files with same name but numbering
e.g wnd20121.grb
wnd20122.grb
.......
wnd2012100.grb
COMMANDS
> cdo -f nc copy fname ofile(s)
(If this is the ofile(s)=output file how can i store it for sequent use ? Take the ofile (output file) from the command and use it / save it as input to the next, producing a new subsequent numbered output set of ofile(s)2)
>cdo merge ofile(s) ofile2
(then automatically take the ofile(s)2 and input them to the next command and so on, producing always an array of new output files with specific set name I set but different numbering for distinguishing them)
>cdo sellon ofile(s)2 ofile(s)3
------------------------------------
To make my question clearer, I would like to know the way in which I can instruct basically through a bash script the terminal to "grab" multiple files that are usually the same name but have a different numbering to make the separate their recorded time
e.g. file1 file2 ...file n
and then get multiple outputs , with every output corresponding to the number of the file it converted.
e.g. output1 output2 ...outputn
How can I set these parameters so the moment they are generated they are stored for subsequent use in the script, in later commands?
Your question isn't clear, but perhaps the following will help; it demonstrates how to use arrays as argument lists and how to parse command output into an array, line by line:
#!/usr/bin/env bash
# Create the array of input files using pathname expansion.
inFiles=(wnd*.grb)
# Pass the input-files array to another command and read its output
# - line by line - into a new array, `outFiles`.
# The example command here simply prepends 'out' to each element of the
# input-files array and outputs each (modified) element on its own line.
# Note: The assumption is that the filenames have no embedded newlines
# (which is usually true).
IFS=$'\n' read -r -d '' -a outFiles < \
<(printf "%s\n" "${inFiles[#]}" | sed s'/^/out-/')
# Note: If you use bash 4, you could use `readarray -t outFiles < <(...)` instead.
# Output the resulting array.
# This also demonstrates how to use an array as an argument list
# to pass to _any_ command.
printf "%s\n" "${outFiles[#]}"