Здравствуйте. Как реализовать передачу переменной скрипту.
Ну например есть скрипт:
#!/usr/bin/expect -fset timeout -1
spawn telnet $SWITCH_IP
match_max 100000
expect -exact "Trying $SWITCH_IP...\r\r
Connected to $SWITCH_IP ($SWITCH_IP).\r\r
Escape character is '^\]'.\r\r
\r
\r
User Access Verification\r
\r
Username: "
send -- "логин\r"
expect -exact "логин\r
Password: "
send -- "пароль\r"
expect -exact "\r
\r
switch10027#"
send -- "conf t\r"
expect -exact "conf t\r
Enter configuration commands, one per line. End with CNTL/Z.\r
switch10027(config)#"
send -- "ip acce "
expect -exact "\r
switch10027(config)#ip access-list "
send -- "e "
expect -exact "\r
switch10027(config)#ip access-list extended "
send -- "155\r"
expect -exact "155\r
switch10027(config-ext-nacl)#"
send -- "per "
expect -exact "\r
switch10027(config-ext-nacl)#permit "
send -- "ip g^H"
expect -exact "ip g^H ^H"
send -- "h "
expect -exact "\r
switch10027(config-ext-nacl)#permit ip host "
send -- "х.х.х.5 a "
expect -exact "\r
switch10027(config-ext-nacl)#permit ip host х.х.х.5 any "
send -- "\r"
expect -exact "\r
switch10027(config-ext-nacl)#"
send -- "exit\r"
expect -exact "exit\r
switch10027(config)#"
send -- "exit\r"
expect -exact "exit\r
switch10027#"
send -- "exit\r"
expect eofОн допустим находится в /home/и называется local
пробую запускать скрипт с параметром
Код:
#/home/local set SWITCH_IP 192.168.0.1
SWITCH_IP=$1 -это добавит в скрипт а запускать
/home/local 192.168.0.1