This will print 4 lines:
ssh root@remote_ip "service iptables restart"
Output:
iptables: Flushing firewall rules: [ OK ]
iptables: Setting chains to policy ACCEPT: filter [ OK ]
iptables: Unloading modules: [ OK ]
iptables: Applying firewall rules: [ OK ]
Same command inside of VAR=$()
VAR=$(ssh root@remote_ip "service iptables restart")
echo $VAR
This time it prints only this line:
iptables: Applying firewall rules: [ OK ]: filter [ OK ]
That line is not even a line from the standard 4 line output.
makes no sense to me.
Also.. I want to see the 4 line output like the original.