ssh to multiple hosts and saving the output in the local host

hi

I have a script to login from a host "A" to a list of hosts in a file and perform some commands inside it...its somethin like this

for i in `cat file`
do
ssh -t $i " command1 ; command2; ..."
done

I wanna save the outputs in a file in the current host "A" i.e from where I am running this script.. Any help pls..

To a file:

for i in `cat file`
do
ssh -t $i " command1 ; command2; ..."
done > output.txt

To the screen and to a file:

for i in `cat file`
do
ssh -t $i " command1 ; command2; ..."
done | tee output.txt
for host in `cat file`
   do
    ssh -T $host <<EOF >>${host_output}
   command1
   command2
   .......
    exit
EOF
 done
 

Thanks a lot...