I\'ve been struggling with this problem when writing a bash script.
Basically, I want to measure the time of a program on a remote server, so I use the command:
/usr/b
"time" command prints result to stderr, not to stdout. Thus it is not piped into your variable.
You should reroute stderr to stdout to achieve what you want:
result=$(ssh host time "command" 2>&1)
And your full code can look something like this:
respond=$(ssh ${fromNode} /usr/bin/time "-f" "%e" "'sh' '-c' 'virsh migrate --live ${VM} qemu+ssh://${toNode}/system > /dev/null 2>&1'" 2>&1)