ポート解放

#!/usr/bin/expect --
log_user 1
set host [ lindex $argv 0 ]
set port [ lindex $argv 1 ]
spawn /usr/bin/telnet $host
expect "assword:" { send "パスワード\r" }
expect ">" {send "enable\r" }
expect "assword:" { send "パスワード\r" }
expect "#" {send "configure terminal\r" }
expect "(config)" { send "interface GigabitEthernet $port \r" }
expect "(config-if)" { send "no shutdown\r" }
expect "(config-if)" { send "exit\r" }
expect "(config)" { send "exit\r" }
expect "#" {send "exit\r" }
expect eof
  • CatOS用
#!/usr/bin/expect --
log_user 1
set host [ lindex $argv 0 ]
set port [ lindex $argv 1 ]
spawn /usr/bin/telnet $host
expect "assword:" { send "パスワード\r" }
expect ">" {send "enable\r" }
expect "assword:" { send "パスワード\r" }
expect "(enable)" { send "set port enable $port \r" }
expect "(enable)" { send "exit\r" }
expect eof