cisco IOS device prompt

Answered Question
Nov 6th, 2008

Hello all Cisco Managment guru! I have a script manuplating cisco device information. I use the log in with read and write privilege and the prompt was " # " now I have changed the privilege to read only and I got ">" prompt and my script can not understand and unable access the device. anybody solve this kind of issue before, how I can write expect script for this prompt.please share your solution

I have this problem too.
0 votes
Correct Answer by Joe Clarke about 7 years 11 months ago

Wasn't able to test it, but try this.

  • 1
  • 2
  • 3
  • 4
  • 5
Overall Rating: 5 (1 ratings)
Joe Clarke Thu, 11/06/2008 - 15:07

If the language is expect, you can use this syntax to match either a '#' or a '>' prompt:

-re {(.*)[#>]$}

eliaspaulos Fri, 11/07/2008 - 07:46

thank you so much J. some reason didn't work. little explanation about my script. it is a cgi ssh expect script. use for log in a Cisco Device using ssh. this ">" prompt not affecting a device using Telent only a device using ssh since using expect script for ssh log in. may be need to put on specific line on the script? like on the bottom or in the top the script.I have attached my expect script. any advice highly appreciated.

eliaspaulos Fri, 11/07/2008 - 11:49

1000000 thank you, it's working great, the minor thing is when I sent you the expect script not pasted the whole line, some expect line for access point missing.I want added that too on new expect but some reason cause the problem.

I have attached the few lines which was missing earlier. if you have time please any suggestion.

Joe Clarke Fri, 11/07/2008 - 11:53

You don't need either of these blocks anymore. What error do you get trying to access an AP?

eliaspaulos Fri, 11/07/2008 - 12:13

thanks J. all commands working on AP's now except "show dot11 association" this command is not working from ">" prompt? because it was working from # prompt. just curios, why only the dot11 association bring no result.

Joe Clarke Fri, 11/07/2008 - 12:42

The command appears to be allowed under disable mode. What error are you getting from the expect script? Are you sure there are clients associated with this AP?

eliaspaulos Fri, 11/07/2008 - 13:06

J. actually another expect script for AP's. I have attached it. that one I thinh need to add the same thing like the previous expect script.where is the good place to add the line you sent me earlier

eliaspaulos Fri, 11/07/2008 - 13:40

everything is working perfect Now!!! thank you so................much!!!! have a great weekend.

eliaspaulos Mon, 12/22/2008 - 08:20

Hi J. Weeks back you helped me about a script to handle privilege mode prompt.(>) it works greatly but for CatOS device the prompt is the same but little bit different as you know.IOS privilege prompt >..... but on CatOs privilege prompt >(space)..... so how I can altered the script to handle this space.

or do I need to start new thread?

my expect currently include.

expect {

-re "\[#>]$" {send "term len 0\r"}

timeout {puts "Error reading prompt -> $expect_out(buffer)";exit}


expect {

-re "\[#>]$" {send "$command\r"}

timeout {puts "Error reading prompt -> $expect_out(buffer)";exit}


expect -re "\[#>]$"

set output $expect_out(buffer)

eliaspaulos Mon, 12/22/2008 - 09:27

thanks again. unfortunately still not working.the only diff I have noticed between Catos and IOS log in. on CatOS "Cisco Systems Console" statement before the banner C . do you think is this cause any problem and my script should expect this.

Joe Clarke Mon, 12/22/2008 - 09:44

I don't see a problem here unless you're using custom prompts. The default CatOS password prompt is:

Enter password:

Your regexp would match that (though I typically use "\[Pp]assword: "). Why do you think you have a password prompt problem?

eliaspaulos Mon, 12/22/2008 - 13:11

I got password prompt error. but that's not a correct message. my script get error message "Timeout error. Is device down or unreachable?? ssh_expect" from this line

( -re "no address.*" {puts "Host error -> $expect_out(buffer)";exit}

timeout {puts "Timeout error. Is device down or unreachable?? ssh_expect";exit}


even though the device is not down and connected.

Joe Clarke Mon, 12/22/2008 - 13:20

Since you didn't post this new script, I cannot say for certain what is causing this. What you did post looks okay. You might try running a sniffer trace, and see where the packet flow is pausing. Then focus your debugging efforts on that area of the script.

eliaspaulos Mon, 12/22/2008 - 13:33

J. I have attached my main script portion showing the log in steps try telnet then call ssh expect script.also attached my expect script. maybe my problem could be here. can see any error?

Joe Clarke Mon, 12/22/2008 - 13:43

I don't know what SSH application you're using, but this looks okay to me. You might try printing the expect buffer when it times out to see what has been read.

eliaspaulos Mon, 12/22/2008 - 13:54

thank you so much J. for your time. how I can print the buffer.actually my script using UNIX PERL. I hope this is my last question. apperciated your help as always!!!

Joe Clarke Mon, 12/22/2008 - 13:56

timeout { puts "Timeout error. Is device down or unreachable?? ($expect_out(buffer)";exit }


This Discussion