FastHandle is fast operation tools for infrastructure configurations and tests.
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
|
fhscripts:get:get_nw_config.sh.html [2017/12/19 02:04] kurihara created |
fhscripts:get:get_nw_config.sh.html [2018/03/29 00:06] (current) kurihara |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ~~NOTOC~~ | ||
| [[: | [[: | ||
| ====== get_nw_config.sh ====== | ====== get_nw_config.sh ====== | ||
| + | $FHHOME/ | ||
| + | \\ | ||
| + | {{INLINETOC}} | ||
| + | \\ | ||
| ===== How to use ===== | ===== How to use ===== | ||
| <sxh bash toolbar: | <sxh bash toolbar: | ||
| - | $ get_nw_config.sh | + | $ get_nw_config.sh |
| </ | </ | ||
| \\ | \\ | ||
| - | ===== Script | + | ===== get_nw_config.sh |
| + | |||
| + | $FHHOME/ | ||
| <sxh bash toolbar: | <sxh bash toolbar: | ||
| Line 19: | Line 23: | ||
| # | # | ||
| # How to use | # How to use | ||
| - | # | + | # |
| # | # | ||
| + | |||
| DEVICE=$1 | DEVICE=$1 | ||
| - | IP=$2 | + | NWIP=$2 |
| - | HOSTNAME=$3 | + | NWHOST=$3 |
| - | USER=$4 | + | NWUSER=$4 |
| - | PASS=$5 | + | NWPASS=$5 |
| + | |||
| + | DATE=`date +%Y%m%d_%H%M` | ||
| + | TFTPSERVER=192.168.0.5 | ||
| + | TFTPUSER=user01 | ||
| + | TFTPDIR=/ | ||
| - | DATE=`date -d '1day ago' +%Y%m%d` | + | CONF=${TFTPDIR}/${NWHOST}/${NWHOST}_${DATE}.conf |
| - | TFTPD=/home/fasthandle/ | + | |
| - | # ------------------------------------------ | ||
| - | HELP () { | ||
| - | cat <<MENU | + | # |
| + | [ ! -d " | ||
| + | chmod 777 ${TFTPDIR} | ||
| + | |||
| + | |||
| + | # | ||
| + | HELP () { | ||
| + | |||
| + | cat <<@ | ||
| How to use | How to use | ||
| get_nw_config.sh | get_nw_config.sh | ||
| - | MENU | + | @ |
| + | |||
| } | } | ||
| - | # ------------------------------------------ | ||
| - | GET_SXR () { | ||
| + | # | ||
| + | GET_SRX () { | ||
| expect -c " | expect -c " | ||
| set timeout 5 | set timeout 5 | ||
| - | spawn ssh ${USER}@${HOST} | + | spawn ssh ${NWUSER}@${NWIP} |
| expect \" | expect \" | ||
| - | send \"$PASSWD\r\" | + | send \"$NWPASSWD\r\" |
| expect \" | expect \" | ||
| send \" | send \" | ||
| expect \"> | expect \"> | ||
| - | send \"show configuration | display set | save USER@192.168.0.5:/ | + | send \"show configuration | display set | save ${TFTPUSER}@${TFTPSERVER}:${CONF}\r\" |
| + | expect \"> | ||
| + | send \"exit\r\" | ||
| interact | interact | ||
| " | " | ||
| } | } | ||
| + | |||
| # | # | ||
| - | case ${NUM} in | + | case ${DEVICE} in |
| -h) HELP | -h) HELP | ||
| ;; | ;; | ||
| Line 65: | Line 81: | ||
| ;; | ;; | ||
| *) HELP | *) HELP | ||
| - | exit | ||
| ;; | ;; | ||
| esac | esac | ||
| + | </ | ||
| - | |||
| - | </ | ||
| \\ | \\ | ||
| - | ===== Example Output ===== | + | \\ |
| + | <WRAP box 90%> | ||
| + | <catlist ..: -noAddPageButton -smallHead -sortAscending> | ||
| + | </ | ||
| + | \\ | ||
| + | \\ | ||
| + | [[: | ||
My Sites
SNS
Copyright (c) 2025 FastHandle - IT Operations Examples All Rights Reserved.