Tasker variable in Expect regex

34 views
Skip to first unread message

Klaus Schumacher

unread,
Dec 5, 2021, 12:00:50 AM12/5/21
to Android Send/Expect
Hello, is it possible to use tasker variables in the Expect regex string the same way they are used in the Send string? I am not talking about getting received data back into tasker which is done via named capture groups. That works fine. What I need is a dynamically created Expect regex.

Example:

Tasker var %request_id is set to 1234
Send: {"id":%request_id,"command":"blah"}\r\n
Expect: \{"id":%request_id,(?<result>.*?)\}

There are several requests sent to the server. Replies are asynchronous and matched to the requests by the "id" key-value pair. When I try the above, Send/Expect replaces the %request_id in the Send string but not in the Expect regex.

Actually sent: {"id":1234,"command":"blah"}\r\n   <-- OK
Actually expected: \{"id":%request_id,(?<result>.*?)\}   <-- NOK, %request_id not replaced by 1234

As a result the Task always fails with a timeout exception.
I cannot just expect any server reply and verify the request_id back in tasker, because the Expect regex would match intermediate replies to other requests and thus finish the task before receiving the actual response to the sent request.

Is there any syntax I am not aware of?

Best regards
Klaus
Reply all
Reply to author
Forward
0 new messages