简体   繁体   English

Bash脚本处理两个文件并循环进行挂载点检查

[英]Bash script to Process two files and loop through to have mountpoint check

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 . 我有两个文件,其中包含主机名,另一个文件中包含我正在从mount.txt文件处理的Linux安装点信息。

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. 我真正要寻找的是登录到每个主机,并检查/tmo/mounts文件中提到的安装点是否在主机上退出(如果退出),然后执行ls -ld mount-point否则跳过它。

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. /home/data/.ans/home/data/.ans是我腐烂登录的rsa密钥。

Hostname File: 主机名文件:

/tmp/hosts 的/ tmp /主机

my-hosts01
my-hosts02

Moun-point File : 点文件:

/tmp/mounts 的/ tmp /坐骑

/data/oracle01
/data/oracle02
/data/oracle03

Please advise and help how could i do that, sorry if i could not make it more readable. 请提供建议和帮助,我该怎么做,如果无法使它更具可读性,对不起。

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 : 知道 :

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM