I have
#!/bin/bash
myfunction(){
ssh "secondnode" 'echo $(dpkg-query -W ${1} 2>&1|awk '''{if ($0 ~ /no packages/) {print "not installed"} else {print "installed"}}''')')
}
VAR1=$(installed "somepackage")
echo $VAR1
the output is always correct for the previous run. To get a correct output for a new run I need to modify the funtion command, for instance add “${1}” and save.
however the same line of myfunction in the terminal (not a script) runs perfectly Seems like the previous output is stored somewhere and never changed…
On the other hand, how can I improve my code with a function to know if a package is installed or not in a remote node. Seems like mine doesn’t work properly
Thanks