Sponsored Content
Top Forums Shell Programming and Scripting Parsing expect_out using regex in expect script Post 302745077 by ashy_g on Sunday 16th of December 2012 02:39:46 PM
Old 12-16-2012
Ok sure,

So the input values are somthing like this

Code:
# show traffic

--------------------------------------------------------------
                      Traffic Statistics
--------------------------------------------------------------
Packets Rx                   |               24644
alid Packets Rx              |               24644
Bytes                        |               99
Valid Byted                  |               45


and i want to write an expect script for login in the router, give the command to dislay these stats and then store them in the script variables to use them .

I am able to log-in the router and give the command but not able to use regex for parsing the expect_out buffer.

Any help is appreciated.

Thanks,
ashy_g

Last edited by Scott; 12-17-2012 at 03:53 PM.. Reason: ICODE tags ===> CODE tags
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Expect: Parsing/evaluating lines of numbers

There *has* to be an elegant way to do this in Expect... I have a command that returns lines of numbers. Like: prompt% mycommand --loop=5 9 4956 4951 4951 4956 9 4960 4951 4951 4956 9 4956 4951 4951 4956 9 4956 4951 4951 4956 9 4956 4951 4951 4956 prompt% All numbers must be... (0 Replies)
Discussion started by: kajkaj
0 Replies

2. Shell Programming and Scripting

strange expect script behavior, or am i misunderstanding expect scripting?

Hello to all...this is my first post (so please go easy). :) I feel pretty solid at expect scripting, but I'm running into an issue that I'm not able to wrap my head around. I wrote a script that is a little advanced for logging into a remote Linux machine and changing text in a file using sed.... (2 Replies)
Discussion started by: v1k0d3n
2 Replies

3. Shell Programming and Scripting

Help with expect expect_out

This is my simple expect scritpt: #!/usr/bin/expect -f match_max 100000 set timeout -1 spawn telnet $IP expect "#" send -- "shell\r" expect "*Ready*" send -- "init\r" expect "*Ready*" send -- "readsensor \r" expect -- "*" <<< Output of this is a 2 digit number set val... (5 Replies)
Discussion started by: expect_user
5 Replies

4. Shell Programming and Scripting

Need help with Expect script for Cisco IPS Sensors, Expect sleep and quoting

This Expect script provides expect with a list of IP addresses to Cisco IPS sensors and commands to configure Cisco IPS sensors. The user, password, IP addresses, prompt regex, etc. have been anonymized. In general this script will log into the sensors and send commands successfully but there are... (1 Reply)
Discussion started by: genewolfe
1 Replies

5. Shell Programming and Scripting

Expect and regex

I'm using Expect to execute a command on a router and return the output to a file. The output is a list. At the end of the list there's a statement that reads, "Found 165 active connections" (Where "165" could be any number between 0 and 2000.) I'm familiar with using Expect to return data from... (2 Replies)
Discussion started by: professorx
2 Replies

6. Shell Programming and Scripting

expect_out buffer no such variable running script background

I am trying to use send and receive using expect. the expect_out(buffer) is working fine while it is running it as foreground. But the same script when it is ran as background, the expect_out(buffer) errored out. Is there any factor influence when we run script in foreground and in background? ... (0 Replies)
Discussion started by: shellscripter
0 Replies

7. Solaris

Help with parsing regex in tripwire for Solaris 10 dfstab

Help with parsing regex in tripwire: the rule is" This test verifies that exported file systems do not have the "root=<host>" option specified." regex that does not work is : ^.*-o+(?=root=\S+|\S+,root=\S+).* the dfstab looks like this : # cat /etc/dfs/dfstab # Place... (1 Reply)
Discussion started by: bathija12
1 Replies

8. Solaris

Help with parsing regex in tripwire for Solaris 10 dfstab FQDN

Help with parsing regex in tripwire: the rule is" This test verifies that all exported file systems found in /etc/exports specify a fully qualified domain name containing "thecss.com" or a NIS netgroup.." regex that does not work is : ... (1 Reply)
Discussion started by: bathija12
1 Replies

9. Solaris

Help with parsing regex in tripwire

We have regex that we use to parse compliance policies in tripwire. can you please help to correct the regex : policy is "Verify That Exported File Systems Specify the ro (read-only) Option" the regex is ^.*-o+(?!ro+|ro\S+|\S+,ro\S+|\S+,ro+).*$ this does not work. how do we fix it ? ... (4 Replies)
Discussion started by: bathija12
4 Replies

10. UNIX for Beginners Questions & Answers

Help with understanding this regex in a Perl script parsing a 'complex' string

Hi, I need some guidance with understanding this Perl script below. I am not the author of the script and the author has not leave any documentation. I supposed it is meant to be 'easy' if you're a Perl or regex guru. I am having problem understanding what regex to use :confused: The script does... (3 Replies)
Discussion started by: newbie_01
3 Replies
IRDPD(8)						      System Manager's Manual							  IRDPD(8)

NAME
irdpd - internet router discovery protocol daemon SYNOPSIS
irdpd [-bsd] [-U udp-device] [-I ip-device] [-o priority-offset] DESCRIPTION
Irdpd looks for routers. This should be a simple task, but many routers are hard to find because they do not implement the router discov- ery protocol. This daemon collects information that routers do send out and makes it available. At startup irdpd sends out several router solicitation broadcasts. A good router should respond to this with a router advertisement. If a router advertisement arrives then no more solicitations are sent. The TCP/IP server has filled its routing table with the info from the advertisement, so it now has at least one router. If the advertisement is sent by a genuine router (the sender is in the table) then the irdpd daemon goes dormant for the time the advert is valid. Routers send new adverts periodically, keeping the daemon silent. Otherwise irdpd will listen for RIP (Router Information Protocol) packets. These packets are sent between routers to exchange routing information. Irdpd uses this information to build a routing table. Every now and then a router advertisement is sent to the local host to give it router information build from the RIP packets. Lastly, if a router solicitation arrives and there is no router around that sends advertisements, then irdpd sends an advertisement to the requestor. Note that this is a direct violation of RFC1256, as no host is supposed to sent those adverts. But alas the world is not always perfect, and those adverts make booting hosts find routers quickly with this help from their brothers. (Of course, they will lose the router soon if they don't have an irdpd daemon themselves.) OPTIONS
-b Broadcast advertisements instead of sending them to the local host only. This may be used to keep (non-Minix) hosts alive on a net without adverts. -s Be silent, do not send advertisements to hosts that ask for them. -d Debug mode, tell where info is coming from and where it is sent. Debugging can also be turned on at runtime by sending signal SIGUSR1 or turned off with SIGUSR2. -o priority-offset Offset used to make the gateway's preferences collected from RIP packets look worse than those found in genuine router adverts. By default -1024. SEE ALSO
set_net_default(8), boot(8), inetd(8), nonamed(8), rarpd(8). BUGS
Under standard Minix this daemon can't listen to two both IRDP and RIP at the same time, so it starts out with IRDP. It switches over to RIP if it can't find a router, or if it threatens to lose its router. It does not switch back. Irdpd may help a host that should not be helped, i.e. if it doesn't have an irdpd daemon with RIP collecting trickery. It will make System Administrators pull out their remaining hair trying to find out why a host can access outside networks for a some time after boot, but goes blind afterwards. AUTHOR
Kees J. Bot (kjb@cs.vu.nl) IRDPD(8)
All times are GMT -4. The time now is 11:00 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy