Кто-нибудь знает, как я могу проанализировать целое число из следующего вывода консоли в ожидаемом тесте?
+-----------------+
| static_route_id |
+-----------------+
| 314 |
+-----------------+
Что я хотел бы сделать, это
proc testRouteId { identity_regex } {
#sign into database (got it)
#fetch routes with matching identity_regex (a column in the database)
send { select static_route_id from static_routes where identity_regex="$identity_regex"; }
send "\r"
#parse the routeId out of the console output somehow
expect {
timeout { send_user "fetchStaticRouteId timed out\n"; return 0 }
eof { send_user "fetchStaticRouteId failed\n"; return 0 }
=========Stuck on the regex =========
-re "REGEX?" { send_user "fetchStaticRouteId $expect_out(1, string)\n" }
}
return routeId; # (an int)
}