I want to save an output of a piped sequence of commands into a variable on a remote server. I'm trying to do it via ssh like this:
ssh $host "kernel_ver=`sudo yum list kernel --showduplicates | grep 7.$os_rel | tr -s " " | cut -d" " -f2 | head -n1`; echo $kernel_ver"
I'm getting this errors:
Error: No matching Packages to list
ssh: Could not resolve hostname kernel_ver= ; echo : Name or service not known
$os_rel is a variable in my script containing a number.
I tried different syntax like: "$( )" to capture the output and it still doesn't work.