Cisco Support Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Announcements
Webcast-Catalyst9k
New Member

cisco IOS device prompt

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

1 ACCEPTED SOLUTION

Accepted Solutions
Cisco Employee

Re: cisco IOS device prompt

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

22 REPLIES
Cisco Employee

Re: cisco IOS device prompt

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

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

New Member

Re: cisco IOS device prompt

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.

Cisco Employee

Re: cisco IOS device prompt

It would be helpful if you posted the script.

New Member

Re: cisco IOS device prompt

here is the script, thank you J.

Cisco Employee

Re: cisco IOS device prompt

Try this one.

New Member

Re: cisco IOS device prompt

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.

Cisco Employee

Re: cisco IOS device prompt

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

New Member

Re: cisco IOS device prompt

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.

Cisco Employee

Re: cisco IOS device prompt

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?

New Member

Re: cisco IOS device prompt

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

Cisco Employee

Re: cisco IOS device prompt

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

New Member

Re: cisco IOS device prompt

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

New Member

Re: cisco IOS device prompt

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)

Cisco Employee

Re: cisco IOS device prompt

Change your regular expressions to:

"\[#>] ?$"

New Member

Re: cisco IOS device prompt

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.

Cisco Employee

Re: cisco IOS device prompt

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?

New Member

Re: cisco IOS device prompt

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.

Cisco Employee

Re: cisco IOS device prompt

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.

New Member

Re: cisco IOS device prompt

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?

Cisco Employee

Re: cisco IOS device prompt

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.

New Member

Re: cisco IOS device prompt

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!!!

Cisco Employee

Re: cisco IOS device prompt

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

259
Views
0
Helpful
22
Replies
CreatePlease to create content