I assume that by "expected output" you mean "
desired output", as the script does exactly what it's supposed to do. It runs two separate commands, and the output from each appears on a separate line.
How about piping the output from
dmidecode through
tr and have it replace the newline character with a space?
Code:
for i in `cat a`; do ssh -q $i -t "/usr/bin/sudo /usr/sbin/dmidecode -s system-serial-number | tr '\n' ' ' ; hostname" ; done
This will cause the output from the
dmidecode and
hostname commands to appear on the same line.