Blacksheep
Blacksheep

Reputation: 1

tcl expect regular expression not working?

I'm trying to expect for different type of network devices but I can't make a more complex regular expression work.

For Cisco devices I have :

expect {"*>"}

The * works fine

But for Fortinet devices I want to do this

expect {"^[a-zA-Z0-9_.-\s]+[#]"}

and it doesn't work. I checked on a REGEX "checker" to make sure the expression is right and it seems to work. So Basically, I want to filter for lines that start with "NAME_OF_DEVICE #" because this is how Fortinet shell is when you first connect to it

Any idea why it won't work?

Upvotes: 0

Views: 639

Answers (1)

Ben
Ben

Reputation: 136

From the manual: "Regexp-style patterns follow the syntax defined by Tcl's regexp (short for "regular expression") command. regexp patterns are introduced with the flag -re."

Your example:

expect -re {^[a-zA-Z0-9_.-\s]+#} ...

Upvotes: 1

Related Questions