This is an old revision of the document!
server# apt install expect
server# cat cisco_change_conf.exp
#!/usr/bin/expect
set sw [lindex $argv 0];
spawn ssh $sw
send "\n"
expect "sword:" { send "cisco\n" }
expect "#" { send "conf t\n" }
expect "#" { send "ip scp server enable\n" }
expect "#" { send "end\n" }
expect "#" { send "write\n" }
expect "#" { send "exit\n" }
send_user "\n"
exit 0
server# chmod +x cisco_change_conf.exp server# ./cisco_change_conf.exp switchN
server# cat /srv/tftp/cisco_change_conf.txt
ip scp server enable end
server# cat cisco_change_conf.exp
...
expect "#" { send "copy tftp://server/cisco_change_conf.txt runn\n" }
send "\n"
send "\n"
...
# cat /usr/share/originate_ami.exp
#!/usr/bin/expect
set username "admin"
set secret "admin"
set host "127.0.0.1"
set port "5038"
set channel [lindex $argv 0];
set num [lindex $argv 1];
set name [lindex $argv 2];
send_user "Args: $channel $num $name\n"
spawn telnet $host $port
expect "Manager" { send "Action: Login\nUsername: $username\nSecret: $secret\n\n" }
expect "Response: Success" {
send "Action: Originate\nChannel: SIP/$channel\nContext: default\nExten: $num\nCallerid: $name<$num>\nPriority: 1\n\n"
}
sleep 5
send "Action: Logoff\n\n"
exit 0
# /usr/share/originate_ami.exp 403 301 "Hello World"