Having a config file with lines similar to that below:
APACHE_SERVER_FLAGS="BLI BLA BLUBB"
How do I check if "APACHE_SERVER_FLAGS" already contains the value SSL at either start, in the middle, or at the end, and add it if it is not present, such that it becomes:
APACHE_SERVER_FLAGS="BLI BLA BLUBB SSL"
As one can see, the separator between key (APACHE_SERVER_FLAGS) and value (BLI BLA BLUBB) is an equal (=) sign, and the separator within the value is a space. The value itself is contained within double quotes.
Any smart way to do this except fiddling with regexes?
UPDATE It could be that "APACHE_SERVER_FLAGS" does not exist at all and should be added with SSL as sole value.
Since we are using a configuration management tool, my recommendation would be to use it as such. Rather than doing checks and modifications, which IMHO is a "scripty" way - it would be better to just render the line as we want.
ssl-config:
file.keyvalue:
- name: /tmp/my-sample.conf
- key: APACHE_SERVER_FLAGS
- value: "\"{{ pillar['apache_flags'] }}\""
- append_if_not_found: True
This will ensure that the appropriate flags are rendered according to pillar data for those machines. We can also use grains, or saltenv to define appropriate configuration.
Related
I want to use values from gradle.properties that should go into a template string.
A naive first:
println("${project.properties[somekey]}")
doesn't work: Unresolved reference: somekey
So, quotes required?
println("${project.properties[\"somekey\"]}")
is completely broken syntax: Expecting an expression for the first .
I couldn't find any example how to do this, yet the official documentation says expressions.
Question: is it possible to access a map in string template, and if so, how?
Yes and as follows:
"${project.properties["someKey"]}"
assuming the Map has the following signature: Map<String, Any?> (or Map<Any...)
Alternatives:
"${project.properties.getValue("someKey")}"
"${project.properties.getOrElse("someKey") { "lazy-evaluation-default-value" }}"
"${project.properties.getOrDefault("someKey", "someFixedDefaultValue")}"
Basically all the code you put in the ${} is just plain Kotlin code... no further quoting/escaping required, except for the dollar sign $ itself, e.g. use "\$test" if you do not want it to be substituted with a variable named test or """${"$"}test""" if you use a raw string
Note that in this println case the following would have sufficed as well (which also goes for all the shown alternatives above. You may omit the outer surrounding quotes and ${} altogether):
println(project.properties["someKey"])
See also Basic types - String templates
I am configuring a XAMPP Apache server to work with wordpress multisites and do not understand the following directive:
"VirtualDocumentRoot "C:/xampp/www/%-2/sub/%-3"
what is the purpose of %-2 and %-3 ?
Forgive the basic nature of my question but I can't seem to understand the mechanics of these two terms. Can anyone point me to where this notation might be explained?
Thanks in advance for any help or direction
Found the answer,
this is known as "Directory Name Interpolation"
Apache explains this here: https://httpd.apache.org/docs/2.4/mod/mod_vhost_alias.html
I've pasted an excerpt:
Directory Name Interpolation
All the directives in this module interpolate a string into a
pathname. The interpolated string (henceforth called the "name") may
be either the server name (see the UseCanonicalName directive for
details on how this is determined) or the IP address of the virtual
host on the server in dotted-quad format. The interpolation is
controlled by specifiers inspired by printf which have a number of
formats: %% insert a % %p insert the port number of the virtual host
%N.M insert (part of) the name
N and M are used to specify substrings of the name. N selects from the
dot-separated components of the name, and M selects characters within
whatever N has selected. M is optional and defaults to zero if it
isn't present; the dot must be present if and only if M is present.
The interpretation is as follows:
0 the whole name
1 the first part
2 the second part
-1 the last part
-2 the penultimate part 2+ the second and all subsequent parts
-2+ the penultimate and all preceding parts 1+ and -1+ the same as 0
If N or M is greater than the number of parts available a single
underscore is interpolated.
I am using robot framework to test a GUI application ,
when I try to run the test case , got an error like
"Element locator with prefix '| id' is not supported " .
But I am using the latest version of selenium2library i.e.2.39.0 .
I will be thankful ,If somebody helps me out regarding the same .
and I have one more query ,i.e. how to click on the contents on GUI when working with robot framework
Thanks in advance
I think the only way you can get such an error message is if you mix two styles of cell separators in your test. For example, you may be mixing tabs and pipes, or multiple spaces and pipes.
Robot determines which format to use on a line-by line basis. First, it looks for a tab anywhere in the line being parsed, and if it finds it, it uses tabs to split the line. If it doesn't find a tab, it checks to see if the line begins with a pipe and space. If so, it uses the pipe for a separator. Failing that, it uses multiple spaces as the separator.
I can reproduce the exact error you are getting by mixing pipes with either a tab or multiple spaces. For example, the following will generate the exact same error you report:
# the next line begins with two spaces
click element | id=treeview_tv_active
Robot will detect the two leading spaces and decide to use spaces to split the line into cells. Thus, the first cell will be "click element" and the second cell will be "| id=treeview_tv_active". Selenium looks for everything before the "=" as the locator type, thus it's using "| id" as the locator, which is invalid and results in the error that you see.
Since you haven't shown us your code it's impossible to say for sure, but my guess is that the line causing the problem begins with a space or tab, or has a tab embedded somewhere else in the line, but later in the same line attempts to use pipes as cell separators.
It seems that the output are the same when I echoed it.
I also tested other commands such as open, but the results from both are the same.
In traditional sh-style pattern matching, * matches zero or more characters in a component of the file name, so there is no difference between *, **, and ***, either on its own or as part of a larger pattern.
However, there are globbing syntaxes that assign a distinct meaning to **. Pattern matching implemented by the Z shell, for example, expands x/**/y to all file names beginning with x/ and ending in /y regardless of how many directories are in between, thus matching all of x/y, x/subdir/y, x/subdir1/subdir2/y, etc. This syntax was later implemented by bash, although only enabled when the globstar configuration option is set by the user.
I believe I have a general understanding on the steps on how to do this, but am struggling to get the schemas correct, either using the Flat File Schema Generator or tweaking the config afterwords.
I will give a sample of the data below, but in general, it starts with a multi-line header that can have variable text but always ends with the same exact line ("START-OF-DATA"). The next section consists of rows of delimited data (this is the only part of the file I need to bring into Biztalk). Finally, there is a multi-line footer that always has the same start end end line ("END-OF-Data" and "END-OF-FILE").
Sample--my comments are in parens:
START-OF-FILE (this is always here)
(. . . variable number of lines that contain info I don't need . . .)
START-OF-DATA (this is always here)
(many lines of delimited data that I DO need)
END-OF-DATA (this is always here)
(. . . variable number of lines that contain info I don't need . . .)
END-OF-FILE (this is always here)
I have used the flat file generator to create three schema (header/detail/footer) with the intent to map only the detail. I created a pipeline and assigned the three schemas to the disassembly stage.
I am looking for general tips on what may be wrong with my approach, or what I should be looking out for. However the error I get when running this is:
The trailer specification specified on the pipeline component
properties does not contain an interchange trailer.
I have googled this error and (as suggested) tried to change the Child order from Infix to Postfix, but this didn't help.
I think this blog should help you:
http://maddcoder.wordpress.com/2012/06/14/using-biztalk-to-parse-a-flatfile-with-multi-line-header-and-trailers/