cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1779
Views
0
Helpful
1
Replies

Expect script problems

I am new to expect and I was using logic to automate disconnecting telnet session where the user is logged in and leave other lines as it is:

for {set i 0} {$i ==4} {incr i} {  
send "clear line vty $i\r"  
"confirm]" {send "\r"}  
"% Not allowed" {send "quit\r"; exit}  
}

it disconnects all the lines

now I use the "show user" command but it's hard for me to write a script around it, the output is not friendly enough for me.so I wrote IF statements in this for loop but it was not good and not even deserving to include here. please can somebody guide me in order to how to match strings in an output result and on the basis of the strings decide to clear line or not

1 Reply 1

balaji.bandi
Hall of Fame
Hall of Fame

There is 2 option you can do.

 

You can configure VTY Lines to discussonect automatically if they are idle 5min, so you do not required this script

line vty 0 4
exec-timeout 5 0

 

Other option is you need to store the output of VTY lines and disconnect  only meet the requirement, Line by Line, more Lines of code required.

 

example :

 

2 vty 1 cisco idle 5w1d 192.168.11.4
* 3 vty 2 cisco idle 00:00:18 192.168.11.14
5 vty 4 cisco idle 00:00:09 192.168.11.15

BB

***** Rate All Helpful Responses *****

How to Ask The Cisco Community for Help

Review Cisco Networking for a $25 gift card