Community discussions

MikroTik App
 
rcanna72
just joined
Topic Author
Posts: 1
Joined: Thu Mar 23, 2023 11:15 am

Using expect to access comand line of Mikrotik

Thu Mar 23, 2023 11:34 am

I want make a script on my linux Debian that connect a Microtik through ssh for execute comand on it
this is my script:

#!/usr/bin/expect

set timeout 60
set password "mypassword"
spawn ssh admin@my.mikrotik
expect "yes/no" {
send "yes\r"
expect "*?assword" { send "$password\r" }
} "*?assword" { send "$password\r" }
expect "\>" { send "\r" }
expect "\] >" { send "system identity print\r"}

Script do login but after print banner of mikrotik I receiv ^[[?6c^[[24;3R and script end,
If add to end of script comand interact after script print ^[[?6c^[[24;3R few minuts ago script continue execute comand system identity print and enter interactive mode
I thing that ^[[?6c^[[24;3R are color code of mikrotik prompt that create problem and comand interact disable it (in interactive mode mikrotik prompt is'nt colored)

how to solve the problem?

Who is online

Users browsing this forum: ko00000000001 and 21 guests