mirror of
https://github.com/tio/tio.git
synced 2026-05-01 14:57:59 +02:00
Updated login example with new expect logic
This commit is contained in:
parent
b0e9fa02e8
commit
29546bb13a
1 changed files with 13 additions and 11 deletions
|
|
@ -1,28 +1,30 @@
|
||||||
local logins = {
|
local logins = {
|
||||||
{
|
["foo"] = {
|
||||||
serialnumber = "foo",
|
|
||||||
username = "foouser",
|
username = "foouser",
|
||||||
password = "foopass",
|
password = "foopass",
|
||||||
},
|
},
|
||||||
{
|
["bar"] = {
|
||||||
serialnumber = "bar",
|
|
||||||
username = "baruser",
|
username = "baruser",
|
||||||
password = "barpass",
|
password = "barpass",
|
||||||
},
|
},
|
||||||
{
|
["baz"] = {
|
||||||
serialnumber = "baz",
|
|
||||||
username = "bazuser",
|
username = "bazuser",
|
||||||
password = "bazpass",
|
password = "bazpass",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, login in ipairs(logins) do
|
send("\n")
|
||||||
send("\n")
|
local found, match_str = expect("\\w+- login:", 10)
|
||||||
local found = expect(login.serialnumber .. ".*login:", 10)
|
if (1 == found) then
|
||||||
if (1 == found) then
|
local model = string.match(match_str, "^%w+")
|
||||||
|
local login = logins[model]
|
||||||
|
if (nil ~= login) then
|
||||||
send(login.username .. "\n")
|
send(login.username .. "\n")
|
||||||
expect("Password:")
|
expect("Password:")
|
||||||
send(login.password .. "\n")
|
send(login.password .. "\n")
|
||||||
break
|
else
|
||||||
|
print("\r\nDon't know login info for " .. model .. "\r\n")
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
print("\r\nDidn't find a login prompt\r\n")
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue