vty expect script

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/OpenBSC@lists.osmocom.org/.

Neels Hofmeyr nhofmeyr at sysmocom.de
Wed Dec 12 15:46:50 UTC 2018


Hi Keith,

I'm now using your vty expect script from
https://gerrit.osmocom.org/#/c/osmo-dev/+/11811/ in our congress gsmcore setup,
and I absolutely love it!

I tweaked the logging, and next to it I also put vty_sticky, which re-opens the
vty when the program gets restarted. Attached my current versions.

Such a simple and nice way to customize logging, easily attach and detach,
quickly change some log levels... much simpler than navigating journalctl.

Thanks for that!
~N
-------------- next part --------------
#!/usr/bin/expect -f
set vty [lindex $argv 0]
set host localhost
switch $vty {
 hlr { set port 4258 }
 bsc { set port 4242 }
 mgw { set port 4243 }
 mgw2 {
        set host 127.0.0.2
        set port 4243
      }
 sg { set port 4245 }
 msc { set port 4254 }
 sip { set port 4256 }
 gg { set port 4260 }
 osmo-hlr { set port 4258 }
 osmo-bsc { set port 4242 }
 osmo-mgw { set port 4243 }
 osmo-mgw-for-bsc { set port 4243 }
 osmo-mgw-for-msc {
        set host 127.0.0.2
        set port 4243
      }
 osmo-sgsn { set port 4245 }
 osmo-msc { set port 4254 }
 osmo-sip-connector { set port 4256 }
 osmo-ggsn { set port 4260 }
 default { set port 4242 }
}
spawn telnet localhost $port
expect ">"
send "enable\r"
expect "#"
send "logging enable\r"
expect "#"
send "logging print category 1\r"
expect "#"
send "logging print category-hex 0\r"
expect "#"
send "logging print level 1\r"
expect "#"
send "logging print file basename last\r"
expect "#"
send "logging print extended-timestamp 1\r"
expect "#"
send "logging level set-all notice\r"
expect "#"
switch $vty {
 msc {
  send "logging level mm info\r"
  expect "#"
  send "logging level cc info\r"
  expect "#"
 }
}
send "logging filter all 1\r"
expect "#"
interact
-------------- next part --------------
#!/bin/sh
while true; do
        vty $@
        sleep 3
done
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.osmocom.org/pipermail/openbsc/attachments/20181212/0e70d76b/attachment.bin>


More information about the OpenBSC mailing list