Skip to content

Instantly share code, notes, and snippets.

@jsfaint
Created March 24, 2017 08:04
Show Gist options
  • Select an option

  • Save jsfaint/f47026fcd1c1aa3ad73f0f308faa9e8c to your computer and use it in GitHub Desktop.

Select an option

Save jsfaint/f47026fcd1c1aa3ad73f0f308faa9e8c to your computer and use it in GitHub Desktop.
Control lanconf with expect
#!/usr/bin/env expect
set timeout 6
set send_slow {1 .1}
spawn ./lanconf32 textmode
expect {
"Press any key to continue." {send -s " ";}
timeout {}
}
expect {
"Enter Device Number or 'exit' to quit" {send -s "1\r";}
timeout {}
}
expect {
"Enter command" {send -s "mode txrx\r";}
timeout {}
}
expect {
"Enter command" {send -s "select 2\r";}
timeout {}
}
expect {
"Enter command" {send -s "mode txrx\r";}
timeout {}
}
expect {
"Enter command" {send -s "txrxall\r";}
timeout {}
}
# Press key
# x: stop
# s to show port statistics
while {1} {
interact {
x {send -s "x"; break}
s {send -s "s"}
-o eof{continue}
}
}
# Press key
# m: more statistics
# d: dump statistics
# other: continue
while {1} {
interact {
m {send -s "m"}
d {send -s "d"; break}
-o eof {break}
}
}
expect {
"Enter command" {send -s "exit\r"}
timeout {}
}
expect {
"Freeing Adapter resources" {}
timeout {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment