I have two files on is which contains host-names and another one which contains Linux mount-point information which i'm processing from file mount.txt
.
What realy I'm looking for is to login to each hosts and check if the mount-point mentioned in the /tmo/mounts
file exits on the hosts if it exits then just do ls -ld mount-point
else skip it.
Somehow being a novice I'm not able to get how to process the mount-point check
#!/bin/bash
REMOTE_HOSTS="/tmp/hosts"
REMOTE_MOUNTS="/tmp/mounts"
awk -F":" '{print $1}' mount.txt | sort -u > $REMOTE_HOSTS
awk '{print $3}' mount.txt | sort -u > $REMOTE_MOUNTS
for hosts in $(cat $REMOTE_HOSTS);
do
echo "------ $hosts ----"
ssh -o StrictHostKeyChecking=no -i /home/data/.ans root@$hosts
done
Side-Note: /home/data/.ans
is my rsa key for rot login.
Hostname File:
/tmp/hosts
my-hosts01
my-hosts02
Moun-point File :
/tmp/mounts
/data/oracle01
/data/oracle02
/data/oracle03
Please advise and help how could i do that, sorry if i could not make it more readable.