[Solved] XLST – Copy XML tag and replace attribute value [closed]

XSLT based solution. Input XML <config> <connection port=”4404″ type=”tcp”> <selection name=”test-mode” enabled=”true”/> </connection> <connection port=”4405″ type=”tcp”> <selection name=”test-mode” enabled=”true”/> </connection> <connection port=”4406″ type=”tcp”> <selection name=”test-mode” enabled=”true”/> </connection> <option> <maxNumberOfDownloads>10</maxNumberOfDownloads> </option> </config> XSLT <?xml version=”1.0″?> <xsl:stylesheet version=”1.0″ xmlns:xsl=”http://www.w3.org/1999/XSL/Transform”> <xsl:output method=”xml” encoding=”utf-8″ indent=”yes” omit-xml-declaration=”yes”/> <xsl:strip-space elements=”*”/> <xsl:template match=”@*|node()”> <xsl:copy> <xsl:apply-templates select=”@*|node()”/> </xsl:copy> </xsl:template> <xsl:template match=”connection[@port]”> <xsl:copy> <xsl:apply-templates … Read more

[Solved] Bash ping script with LCD error message errors

The following lines of code in your program aren’t C at all. They look like a fragment of shell script: lcd_command(LINE_3); {while true; do ping -c1 192.168.10.30 2>&1 /dev/null; //VPN IP lcd_writechars(“STS300”);} {if [[ ! $? ]]; then lcd_writechars(“VPN Lost”); fi; sleep 10; } This won’t work. Rewrite this code in C. (The system() function … Read more

[Solved] Shell Script – Adding memory functionality

You should store the result in a variable like this: result=$((operand1+operand2)) Then your first if statement can check if this variable has a value, and if it does, skip the read and use it instead. if [[ $result == “” ]]; then echo Enter operand1 value: read operand1 else operand1=$result echo “Operand 1 is: $result” … Read more

[Solved] Remove newlines between two words

something like this? kent$ awk ‘/^key.:/{p=1}/^name:/{p=0} {if(p)printf “%s”,$0;else printf “%s%s\n”, (NR==1?””:RS),$0}’ file name: charles key1: howareyou? name: erika key2: I’mfine,thanks name: … handle the spaces: awk ‘/^key.:/{p=1}/^name:/{p=0} {if(p)printf “%s%s”,(/^key.:/?””:” “),$0; else printf “%s%s\n”, (NR==1?””:RS),$0}’ file output: name: charles key1: how are you? name: erika key2: I’m fine, thanks name: … 2 solved Remove newlines between … Read more

[Solved] Array from a file

Quotes fix everything: while read line do IFS=’:’ read -ra ADDR <<< “$line” echo ${ADDR[0]} echo ${ADDR[1]} done < file.txt Quoting the variable “$line” is what made the difference. If you’re not getting the line with “C:c”, it’s probably because your file is missing a final newline. solved Array from a file

[Solved] When can I run a shell script with command “. shellscript” in bash,ubuntu?

The Bash shell searches the directories listed in the PATH variable in both shellscript and . shellscript cases. The main difference is that when using . (or equivalently source) to start a script, a new shell process is not created for interpreting the script. This is sometimes useful because it allows the script to define … Read more

[Solved] How do i execute shell script using java

This is a simple code to execute the shell script and read its output: import java.io.*; public class Test { public static void main(String[] args) throws Exception { String[] command = { “./flows.sh”, “suspend” }; Process process = Runtime.getRuntime().exec(command); BufferedReader reader = new BufferedReader(new InputStreamReader( process.getInputStream())); String s; while ((s = reader.readLine()) != null) { … Read more

[Solved] Replacing string with variable with Groovy and SED command

In Groovy variable/expression substitution inside of strings (interpolation) only works with certain types of string literal syntax. Single quote syntax (‘content’) is not one of them. However, if you replace the outer single quotes with double quotes (“content”) then you should get the interpolation effect you are looking for: def sDescription = “foo” def sedCommand … Read more