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/18 22:55]
kurihara ↷ Page name changed from preparation:fhhost.html to preparation:fhghost.html
preparation:fhhome:fhghost.html [2019/02/12 23:28] (current)
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
 # #
 #=========================================================== #===========================================================
  
-case "$1" in +help(){ 
-    -a | --all | -t | --test +cat << @ 
-        FLG="TRUE" +Example 
-        shift +  fhghost.sh  FILE 
-        ;; +  fhghost.sh  PATTERN FILE 
-    -h | --help ) +  fhghost.sh  "*" FILE 
-        echo  "Exxample:" +
-        echo  "fhgh.sh  PATTERN FILE" +}
-        echo  "fhgh.sh  "*" FILE" +
-esac+
  
 +if [ "$#" -eq 0 ] ; then
 +    help
 +    exit 0
 +fi
  
-PATTERN="$1" 
-FILE="$2" 
  
-if [ "$FLG" = "TRUE" ]; then +if [ "$#-eq 1 ] ; then 
-    grep -Ev "^#|^$" "${FILE}"  grep -"${PATTERN}+ 
-else +    case "$1in 
-    grep -Ev "^#|^$" "${FILE}"  | grep -E "${PATTERN}" | awk {'print $1'}+        -h | --help ) 
 +            help 
 +            exit 0 
 +            ;; 
 +        * ) 
 +            FILE="$1
 +            grep -Ev "^#|^$" "${FILE}"  | awk {'print $1'} 
 +            ;; 
 +    esac
 fi fi
  
 +if [ "$#" -eq 2 ] ; then
  
-exit 0+    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.1511013324.txt.gz · Last modified: 2017/11/18 22:55 by kurihara