0

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.

Community
  • 1
  • 1
user2023
  • 452
  • 5
  • 22
  • you can give the command(s) to ssh via stdin. possible `echo "hostname; ls -la /data/oracle01; ls -la /data/oracle02" | ssh -o StrictHostKeyChecking=no -i /home/data/.ans root@$hosts` is helpfully – gmu May 03 '19 at 09:54
  • @gmu, thnx for the direction i can do that with ssh command itself if i have few mounts but i need them to be processed from a file which is in my case. – user2023 May 03 '19 at 10:07

1 Answers1

1

You have to make a difference between a mount-point, which is simply a directory, and a mounted element, which can be a storage or another thing.

Knowing that :