FastHandle - IT Operations Examples

FastHandle is fast operation tools for infrastructure configurations and tests.

User Tools

Site Tools


Sidebar


Top     SiteMap

Manager Server

Target Server

$FHHOME/bin/xxx.sh | xxxx.exp













.

preparation:fhhome:fhghost.html



This is an old revision of the document!


Top#Preparation

fhscripts/fhghost.sh

#!/bin/bash
#===========================================================
# fhghost.sh    FastHandle Grep Host
#
# How to use
#    fhghost.sh  -h
#    fhghost.sh  FILE
#    fhghost.sh  "*"  hosts/xxxx    <- like grep PATTERN FILE
#    fhghost.sh  PATTERN FILE       <- like grep PATTERN FILE
#
#===========================================================

help(){
    echo  "Exxample:"
    echo  "fhghost.sh  FILE"
    echo  "fhghost.sh  PATTERN FILE"
    echo  "fhghost.sh  "*" FILE"
}

if [ "$#" -eq 0 ] ; then
    help
    exit 0
fi


if [ "$#" -eq 1 ] ; then

    case "$1" in
        -h | --help )
            help
            exit 0
            ;;
        -a | --all | -t | --test | -v )
            FILE="$1"
            grep -Ev "^#|^$" "${FILE}"
            ;;
        * )
            FILE="$1"
            grep -Ev "^#|^$" "${FILE}"  | awk {'print $1'}
            ;;
    esac
fi

if [ "$#" -eq 2 ] ; then

    case "$1" in
        -a | --all | -t | --test | -v )
            FILE="$2"
            grep -Ev "^#|^$" "${FILE}"
            ;;
        * )
            PATTERN="$1"
            FILE="$2"
            grep -Ev "^#|^$" "${FILE}"  | grep -E "${PATTERN}" | awk {'print $1'}
            ;;
    esac

fi




Top#Preparation



preparation/fhhome/fhghost.html.1514729442.txt.gz ยท Last modified: 2017/12/31 23:10 by kurihara