Sponsored Content
Top Forums Shell Programming and Scripting comprehensive expect examples Post 302356276 by Gavster on Friday 25th of September 2009 04:33:50 AM
Old 09-25-2009
Hi,

I wrote an expect script to log in to all cisco switches on our network which uses telnet. The main problem for me was that the usernames and passwords weren't consistent across all switches. My code looked like this ...
Code:
log_file -noappend ./CDP_LOGS/$ip_addr.log
# This spawns the telnet program and connects it to the IP address
 spawn telnet $ip_addr
 #The script expects Password or Username or times out if no response is seen
 expect {
   "Password: "  {login1a $ip_addr}
   "Username: "  {login2a $ip_addr}
   timeout       {abort $ip_addr 1}
 }
 log_file

If "Password: " or "Username: " are identified, the appropriate proc is called (either login1a or login2a respectively). Once logged in successfully, you can continue to send commands using this construct:
Code:
send "command"
 while {1} {
   expect "some output 1" {
     do stuff
   } "some output 2" {
     do stuff
     break
   } "some output 3" {
     do stuff
     break
   }
 }

This expects multiple things and reacts accordingly.

All my output was logged to a file which I used for post-processing.

Hope this is helpful.

Gavin

Last edited by Gavster; 09-25-2009 at 11:06 AM..
 

2 More Discussions You Might Find Interesting

1. Solaris

Comprehensive system documentation by button click

Guys There's a new WebPage where you can generate a comprehensive detailed system documentation by button click. Look at the example at https://sdoctool.sun.com/data/doc.php?ID=sdoctool&N=2 ;) Interested, go to Cheers (0 Replies)
Discussion started by: lebch
0 Replies

2. Red Hat

Comprehensive Disk & Server Logs.

Hello All, I'm using a RHEL6.4 on IBM X3850 X5 server. I want to get a comprehensive report containing disk-wise health status as well as overall server status. I see there's utility "ibm_utl_dsa_dsytd3h-9.51_portable_rhel6_x86-64.bin" which is also used to do diagnostics tasks. I'm not sure of... (1 Reply)
Discussion started by: vaibhavvsk
1 Replies
ATMARP(8)						       Maintenance Commands							 ATMARP(8)

NAME
atmarp - administer classical IP over ATM connections SYNOPSIS
atmarp -a atmarp -c [[atm]number] atmarp -q ip_addr [qos qos] [sndbuf bytes] atmarp -s ip_addr [itf.]vpi.vci [qos qos] [sndbuf bytes] [temp] [pub] [null] atmarp -s ip_addr atm_addr [qos qos] [sndbuf bytes] [temp] [pub] [arpsrv] atmarp -d ip_addr [arpsrv] atmarp -V DESCRIPTION
atmarp is used to maintain the ATMARP table of the ATMARP demon. The table can be listed, new PVC and SVC entries can be added, and exist- ing entries can be deleted. In addition to that, atmarp is also used to create new IP over ATM interfaces. Note that the kernel has its own ATMARP table containing only entries for destinations to which a connection exists. The table of atmarpd can also contain currently unused entries. OPTIONS
-a list the current ATMARP table. -c create the specified IP interface. If the interface number is omitted, the operating system assigns the next free number and atmarp prints the resulting interface name (e.g. `atm0') on standard output. -q sets the QOS and the send buffer size to use as the default for all VCs generated for that IP network (ip_addr must be the address of the network). -s set up a PVC or create an SVC entry. The following options are recognized: qos qos uses the specified quality of service (see qos(7) for the syntax). UBR at link speed is used by default. sndbuf bytes tries to set the send buffer to the specified number of bytes. A system default value is used if sndbuf is not specified. temp does not mark the entry as permanent, i.e. it will time out and then be removed. pub publishes the entry (only relevant for ATMARP server). ATMARP requests for entries not marked for publishing yield an ATMARP_NAK response. null uses NULL encapsulation instead of LLC/SNAP encapsulation on the PVC. This option is not available for SVCs, because the LLC/SNAP header is required to identify ATMARP packets. null also implies that the entry is permanent. arpsrv identifies the entry pointing to the ATMARP server. Note that the node acting as the ATMARP server must have no ATMARP server entry in its ATMARP table. -d delete the specified ARP entry. In order to prevent accidental deletion of the ATMARP server entry, the arpsrv flag must be speci- fied when deleting it. -V print the version number of atmarp on standard output and exit. FILES
/var/run/atmarpd.table ATMARP table AUTHOR
Werner Almesberger, EPFL ICA <Werner.Almesberger@epfl.ch> SEE ALSO
atmarpd(8), clip(8), qos(7) Linux April 26, 2000 ATMARP(8)
All times are GMT -4. The time now is 10:21 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy