I am ssh to many servers to get some information... however sometimes the server is unreacheable and i am getting an error. I want to save that output to a file but I am not able to do so...
I want to be able to save output of bash into a file.. so when I run this command on a script
ssh abhapp01i.abh-sort.us.dhl.com
I get this line, saved into a file...
ssh: abhapp01i.abh-sort.us.dhl.com: Temporary failure in name resolution
I do this for may servers and I want to know to which servers I can login or not...
This is my current script...
for host in `cat $PATH_TEMP/servers_test.txt`
do
#LINUX SERVERS
# var=`ssh $host uname -n`
# echo -n $var ";">> $PATH_TEMP/valeria/reporte_test
echo -n $(ssh $host cat /usr/openv/netbackup/exclude_list) >> $PATH_TEMP/valeria/reporte_test
echo >> $PATH_TEMP/valeria/reporte_test
done
this is the output on my bash when I run the script
[root@harp valeria]# sh unix_servers_test.sh
ssh: abhmq01.abh-sort.us.dhl.com: Temporary failure in name resolution
ssh: abhxdb01d.abh-sort.us.dhl.com: Temporary failure in name resolution
ssh: admpae1-65.phx-dc.dhl.com: Name or service not known
What I want is to have the previos lines added to my file, because the current file I end up looks like this...
/tmp/ /var/tmp/ /var/spool/mqueue /var/spool/sockets /usr/tmp/ /cdrom/ /SD_CDROM/ /mnt/ /tmp_mnt/ /dev/fd/ /proc/ /INFORMIXTMP/ /etc/mnttab core /Contentstore
_AMNO_PROD/ /Contentstore_AMNO_PROD_2/
/tmp/ /var/tmp/ /var/spool/mqueue /var/spool/sockets /usr/tmp/ /cdrom/ /SD_CDROM/ /mnt/ /tmp_mnt/ /dev/fd/ /proc/ /INFORMIXTMP/ /etc/mnttab core
So the first 3 lines that I see on my bash when I run my script need to be added to the file in order to end up with a file like this..
ssh: abhmq01.abh-sort.us.dhl.com: Temporary failure in name resolution
ssh: abhxdb01d.abh-sort.us.dhl.com: Temporary failure in name resolution
ssh: admpae1-65.phx-dc.dhl.com: Name or service not known
/tmp/ /var/tmp/ /var/spool/mqueue /var/spool/sockets /usr/tmp/ /cdrom/ /SD_CDROM/ /mnt/ /tmp_mnt/ /dev/fd/ /proc/ /INFORMIXTMP/ /etc/mnttab core /Contentstore
_AMNO_PROD/ /Contentstore_AMNO_PROD_2/
/tmp/ /var/tmp/ /var/spool/mqueue /var/spool/sockets /usr/tmp/ /cdrom/ /SD_CDROM/ /mnt/ /tmp_mnt/ /dev/fd/ /proc/ /INFORMIXTMP/ /etc/mnttab core
HOW CAN I ACCOMPLISH THIS, THANK YOU!!