How to edit spring xml file [duplicate] - shell

I want to change a value (i.e., value="false") using Shell Script. How could I go about doing that. Please provide me with any suggestion.
What I have tried / used:
I used command-> sed 's/true/false/g' ml.xml.
Problem:
But all true content changed.
What I would like:
My requirement entails that only a certain specific content to be changed, not every content.
Before: property name="s" value="true"
After: property name="s" value="false"
ml.file
<bean id="a"
class="com.s.analyzer.Analyzer" scope="singleton">
<!-- *** CHANGE to true for first daily run, otherwise false *** -->
<property name="s" value="true" />
<property name="a1l" value="2.5" />
<property name="mi" value="2000" />
<property name="ma" value="1" />
</bean>

Using xml tools would be much better here. See for example how to do this with xmlstarlet:
xmlstarlet ed --ps --inplace --update '//bean/property[#name="s"]/#value' -v false ml.xml

This is an exact match (of <property name="s" value="true):
sed -e "s/\(<property name=\"s\" value=\"\)true/\1false/g" file
To change the file inplace:
sed -i "s/\(<property name=\"s\" value=\"\)true/\1false/g" file
If you want an exact match of <property name="s" value="true" />, then:
sed -e "s/\(<property name=\"s\" value=\"\)true\(\" \/>\)/\1false\2/g" file

Related

How To Reference Yaml File Relative to Launch File?

I have a launch file that is loading a yaml file:
<launch>
<rosparam command="load file="filename.yaml" />
<node pkg="my_package" type="my_package_node" name="my_package_node" />
</launch>
The filename.yaml file cannot be found unless I put a complete path: "/home/username/blah/blah/blah". Seeing as this launch file is used on multiple machines by different users and locations for the repository, I obviously cannot hard-code the path. So now what? How do I reference it relative to the location of the launch file?
we can set environment variable PWD for the specified node, eg we'd like to pass a rviz configuration file to rviz, the relative path can be like this:
<arg name="rviz_file" value="$(eval env('PWD')+'/config/showme.rviz')"/>
<node name="rviz" pkg="rviz" type="rviz" args="-d $(arg rviz_file)" required="true" />
Best answer I could find myself was to use $(find package_name) as a starting point:
<launch>
<rosparam command="load file="$(find package_name)/../../yamlFolder/filename.yaml" />
<node pkg="my_package" type="my_package_node" name="my_package_node" />
</launch>
Seems kinda silly though. No reference to the path relative to the launch file itself? Would definitely like a better answer.
If You are using ROS Packages, Launch Folders Are in the root folder of Package So $(find package) are actually one folder before your launch file
If your yaml file is in a ROS package, then I think using the find substitution arg as you do in your answer is the cleanest route. If it's someplace else, I would suggest leveraging environment variables with something like
<launch>
<arg name="yaml_path" default="$(optenv YAML_PATH)"/>
<arg if="$(eval yaml_path == '')" name="yaml_file" value="$(env HOME)/some_folder/filename.yaml" />
<arg unless="$(eval yaml_path == '')" name="yaml_file" value="$(arg yaml_path)/filename.yaml"/>
<rosparam command="load" file="$(arg yaml_file)"/>
</launch>
This kind of gives the best of all worlds. If you've set YAML_PATH as an environment variable (e.g. export YAML_PATH="$HOME/some_path" from terminal or in your bashrc) then the path for yaml_file will use it. If not, optenv will evaluate to an empty string and the arg yaml_file will be set to some default path relative to your home folder. AND, if you have a user that doesn't want to mess with the environment variables at all, they can still pass in a path manually by calling it like
roslaunch my_launch_file.launch yaml_path:=/home/my_name/my_preferred_folder

Applescript cannot recognize valid command from SDEF file

I created valid SDEF file, that contains among other stuff a command:
<command name="abc" code="abc01234" description="do abc">
<cocoa class="ABCCommand"/>
<direct-parameter description="a text parameter passed to the command">
<type type="text" list="yes" optional="yes"/>
</direct-parameter>
<parameter name="abc1" code="abc1" type="text" optional="yes"
description="abc1">
<cocoa key="abcKey1"/>
</parameter>
<parameter name="abc2" code="abc2" type="text" optional="yes"
description="abc2">
<cocoa key="abcKey2"/>
</parameter>
<parameter name="abctrue" code="abct" type="boolean" optional="yes"
description="xxxxxx">
<cocoa key="abctrue"/>
</parameter>
<result type="list of text" description="returns ABC"/>
</command>
Then I set the 'scriptable' flag to YES and compiled the program exactly as all guides recommend.
Now I created Applescript:
tell application "xxx123"
activate
delay 3
abc
delay 3
abc {}
delay 3
abc {"abc", "123"} without abctrue
quit
end tell
The problem is that Applescript being run from AS editor does not recognize 'abc' as command and complains on syntax error. Also in line 'abc {"abc", "123"} without abctrue' it says that 'abctrue:false' cannot follow the '}'. Any changes made in SDEF do not affect the syntax issues. So the question is: how to ensure that Applescript addresses up-to-date SDEF?

Windows batch script to replace a string

I have a txt file that looks like this:
file: config.txt
property name="java.nio.preferSelect" value="true"
property name="pico.rcp.platform.host" value="172.22.3.11"
property name="pico.rcp.platform.port" value="6790"
I want a windows batch script that will search for "pico.rcp.platform.host" string and change the IP value in that line regardless its value to the passed value in the command line. Like the following:
changeServerTo.bat "172.22.3.1" config.txt
the above script should make the file looks like this:
file: config.txt
property name="java.nio.preferSelect" value="true"
property name="pico.rcp.platform.host" value="172.22.3.1"
property name="pico.rcp.platform.port" value="6790"
and
changeServerTo.bat "172.22.100.221" config.txt
should make the file looks like this:
file: config.txt
property name="java.nio.preferSelect" value="true"
property name="pico.rcp.platform.host" value="172.22.100.221"
property name="pico.rcp.platform.port" value="6790"
and so on.
Your help is much appreciated.
Thanks in advance.
This script just rewrites the entire file and uses the parameter in the output
echo property name="java.nio.preferSelect" value="true" >config.txt
echo property name="pico.rcp.platform.host" value=%1 >>config.txt
echo property name="pico.rcp.platform.port" value="6790" >>config.txt

PropertyGrid ValueEditor for a file name

I have the following rule definition:
<Rule ...>
<... />
<StringProperty Subtype="file" ...>
<StringProperty.ValueEditors>
<ValueEditor EditorType="DefaultStringPropertyEditor" DisplayName="<Edit...>"/>
<ValueEditor EditorType="DefaultFilePropertyEditor" DisplayName="<Browse...>"/>
</StringProperty.ValueEditors>
</StringProperty>
<... />
</Rule>
It adds the "<Edit...>" and "<Browse...>" options for editing a property, but the Browse dialog asks for an *.exe file, when I need to let user select a *.txt file. There is a combobox in the dialog that allows to choose "All files .", but really that's not an option.
I have tried to find a solution but this extensibility bit does not seem to be well documented.
I have finally found a way to do that, yet for VS2012 only. Putting a metadata piece named Filters with the filters string in the typical open file dialog format seems to do the trick now.
Example:
<ValueEditor EditorType="DefaultFilePropertyEditor" DisplayName="<Browse...>">
<ValueEditor.Metadata>
<NameValuePair Name="Filters" Value="Text (*.txt)|*.txt" />
</ValueEditor.Metadata>
</ValueEditor>

How to get Chirpy to update mashed files when edits are made

I've just begun using Chirpy, and it's frigging amazing. One problem I'm having is that I'm unable to get it to update the mashed file(s) when an edit is made in one of the "sub" files.
IE: If I have a mashed file called "site.css" (via my js.chirp.config file) which contains "elements.css", "master.css", "misc.css" etc. And I make an edit to one of them (say, master.css), I want chirpy to kick in and redo the site.css with the new edits.
Is this at all possible?
Chirpy does this - just make sure your paths use backslashes rather than forward slashes.
<root>
<FileGroup Name="site.css">
<File Path="css\elements.css" />
<File Path="css\master.css" />
<File Path="css\misc.css" />
</FileGroup>
</root>
Chirpity chirp chirp chirp.
I have
<Folder Pattern="*.min.css" Minify="false" />
And with that wildcard in there, it doesnt run when min.css files are updated. I have to update the config and save for the mash to occur

Resources