eczema/ciscocmd-cosi

couldn't compile regular expression pattern: quantifier operand invalid

Closed this issue · 5 comments

Hi
I am not a well experienced programmer but google could not help me out with this issue
If I ssh to a Cisco switch I get the following error .

Processing... LAB-SW32
couldn't compile regular expression pattern: quantifier operand invalid
while executing
"expect -nobrace -re {'@'.
} {
set macro 1
if { [ info exist logfd ] && $logger == 1 } {
regsub -all -- "^G" $expect_out(buffer) "" add
..."
invoked from within
"expect {
-re "'@'.\r\n" {
set macro 1
if { [ info exist logfd ] && $logger == 1 } {
regsub -all -- "^G" $expect_out(buffer) "" add
..."
(procedure "waitprompt" line 20)
invoked from within
"waitprompt "
("foreach" body line 70)
invoked from within
"foreach host $hostlist {
#####################
# Login to the host #
#####################

    if { [ info exist debugfile ] } {
            if { $FORK == 1 ||..."

And I don‘t know how to solve it .
Tried Telnet as well with the same result and ciscocmd on different Linux Distros without success.
What‘s wrong on that Regex ?
Regards Markus

Brainstorming:

  1. What TCL version are you using?

  2. I see the current code has a backslash before the dot: "'@'\.\r\n". I wonder if this is difference is just an artifact of the error output. Can you check if your expect code matches the one in the repo?

  3. What version of ciscocmd are you using? Can you try the latest one?

Hi
thanks for your response

1.) Using tcl version
mac> tclsh
% puts $tcl_version
8.4
% info patchlevel
8.4.11
%

  1. that´s the script sniplet
    } else {
    expect {
    -re "'@'.\r\n" {
    set macro 1

seems to be OK, but it is still the same behavior
Note: copy pasted the correct regex sniplet you mentioned above into this window and as soon i did send the comment you can´t see anymore the \ in front of the .\r\n" maybe a github issue ?

3.) usind the latest ciscocmd V1.11

It's difficult to check without the exact output if Github is altering it. I am noticing something in your first message, though:

while executing
"expect -nobrace -re {'@'.
} {
set macro 1

invoked from within
"expect {
-re "'@'.\r\n" {
set macro 1

The extra closing bracket } before the first set macro line may mean something but I don't know what. I would try downloading the file again, directly from Github. I wonder if an incorrect end-of-line is messing up with the script execution.

Also, it would be interesting to check if this works with an older version. If it does not, it's most likely an environment issue or a bad source code. If it does, though, then doing a git bisect and finding out what commit makes it break would be great to get more information.

Hi
Finaly the issue is solved by download the ciscocmd tar.gz file and this works.
what surprises me is when you copy/paste the raw version into a new file it wount work.
I expected that there are no issues if you copy plain text from the raw page because that will be the same as if you would download the file.

I am glad that it worked for you. Thank you for sharing your findings. It can certainly be of help to someone else that faces the same issue. I will close this issue.