FastHandle - IT Operations Examples

FastHandle is fast operation tools for infrastructure configurations and tests.

User Tools

Site Tools


preparation:fhhome:fhghost.html



Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
preparation:fhhome:fhghost.html [2017/11/13 01:10]
kurihara ↷ Page moved from install:fhhost.html to preparation:fhhost.html
preparation:fhhome:fhghost.html [2019/02/12 23:28]
kurihara
Line 1: Line 1:
-====== fhghost.sh ======+[[:index.html#Preparation|Top#Preparation]] 
 +====== $FHHOME/fhscripts/fhghost.sh ====== 
 + 
 +\\ 
 +{{INLINETOC}} 
 +\\ 
 + 
 + 
 +===== Operation ===== 
 +<sxh bash toolbar:false gutter:false> 
 +$ fhghost.sh  -h 
 + 
 +$ fhghost.sh  FILE  |fab  -- hostname 
 +$ fhghost.sh  "*"  hosts/xxxx  |fab  -- hostname 
 +$ fhghost.sh  PATTERN FILE  |fab  -- hostname 
 +</sxh> 
 + 
 + 
 + 
 +\\ 
 +===== fhghost.sh ===== 
 +$FHHOME/fhscripts/fhghost.sh
  
 <sxh bash toolbar:false gutter:false> <sxh bash toolbar:false gutter:false>
 #!/bin/bash #!/bin/bash
 #=========================================================== #===========================================================
-# FastHandle Grep Host+fhghost.sh    FastHandle Grep Host
 # #
-fhgh.sh  "*"  hosts_xxxx     like grep PATTERN FILE +How to use 
-fhgh.sh  PATTERN FILE        like grep PATTERN FILE+#   Help 
 +#     fhghost.sh  -h 
 +#   Test 
 +#     fhghost.sh -a FILE 
 +#   pipe to Fabric 
 +#     fhghost.sh  FILE | fab xxx 
 +#     fhghost.sh  "*"  hosts/xxxx |fab xxx  <- like grep PATTERN FILE 
 +    fhghost.sh  PATTERN FILE |fab xxx     <like grep PATTERN FILE
 # #
 #=========================================================== #===========================================================
  
-PATTERN="$1" +help(){ 
-FILE="$2"+cat << @ 
 +Example 
 +  fhghost.sh  FILE 
 +  fhghost.sh  PATTERN FILE 
 +  fhghost.sh  "*FILE 
 +
 +}
  
-grep -Ev "^#|^$"  "${FILE} | grep -E "${PATTERN}"  &> /dev/null +if [ "$#" -eq 0 ] ; then 
-if [ $? -ne 0 ] ; then +    help 
-    echo "" +    exit 0
-    echo "ERROR" +
-    echo "How to use" +
-    echo "fhgh.sh  PATTERN FILE " +
-    exit 1+
 fi fi
  
-grep -Ev "^#|^$" "${FILE}"  | grep -E "${PATTERN}" | awk {'print $1'} + 
-exit 0+if [ "$#" -eq 1 ] ; then 
 + 
 +    case "$1" in 
 +        -h | --help ) 
 +            help 
 +            exit 0 
 +            ;; 
 +        * ) 
 +            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
 </sxh> </sxh>
  
 +\\
 +<WRAP box 90%>
 +[[:index.html#Preparation|Top#Preparation]]
 +<catlist ..: -noAddPageButton -noHead>
 +</WRAP>
 +\\
 +[[:index.html#Preparation|Top#Preparation]]


preparation/fhhome/fhghost.html.txt · Last modified: 2019/02/12 23:28 by kurihara