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













.

fhscripts:get:get_nw_config.sh.html



FastHandle Scripts

get_nw_config.sh

$FHHOME/bin/get_nw_config.sh


How to use

$ get_nw_config.sh  srx  192.168.0.5  test-fw-01 root  password


get_nw_config.sh

$FHHOME/bin/get_nw_config.sh

#!/bin/bash
#===============================================
# get_nw_config.sh
#
# How to use
#     get_nw_config.sh  srx  x.x.x.x  test-fw-01  root  password
#===============================================
 
DEVICE=$1
NWIP=$2
NWHOST=$3
NWUSER=$4
NWPASS=$5
 
DATE=`date +%Y%m%d_%H%M`
TFTPSERVER=192.168.0.5
TFTPUSER=user01
TFTPDIR=/home/fasthandle/fhhome/tftp

CONF=${TFTPDIR}/${NWHOST}/${NWHOST}_${DATE}.conf


#----------------------------------------------------------
[ ! -d "${TFTPDIR}" ] && mkdir ${TFTPDIR}
chmod 777 ${TFTPDIR}


#----------------------------------------------------------
HELP () {
 
cat <<@
How to use
      get_nw_config.sh  srx  x.x.x.x  test-fw-01 root  password
@
 
}


#-------------------------------------------
GET_SRX () {

expect -c "
set timeout 5
spawn ssh  ${NWUSER}@${NWIP}
expect \"assword:\"
send \"$NWPASSWD\r\"
expect \"%\"
send \"cli\r\"
expect \">\"
send \"show configuration | display set | save ${TFTPUSER}@${TFTPSERVER}:${CONF}\r\"
expect \">\"
send \"exit\r\"
interact
"
}
 
#===========================================
case ${DEVICE} in
  -h) HELP
    ;;
  srx|SRX) GET_SRX
    ;;
  *) HELP
     ;;
esac




fhscripts





FastHandle Scripts



fhscripts/get/get_nw_config.sh.html.txt ยท Last modified: 2018/03/29 00:06 by kurihara