Multiple Telnet sessions through one script

2006-07-31 Thread vmalhotra
Hi

I am new in python scripting. I want to open a Multiple telnet session
through once script. In other way i can tell i want to open two linux
consoles through one script.

I wrote one script, but the issue is I am not able to open multiple
consoles. The Scripts which i wrote is as follows:

import pexpect
session = pexpect.spawn("telnet localhost 2601\n")
session.expect("Password: ")
session.send("XYZ\n\n")
session.expect("Router1> ")
session1 = pexpect.spawn("telnet localhost 2604\n")
session1.expect("Password: ")
session1.send("ABCD\n\n")
session1.expect("ospfd> ")
#session1.interact()
session1.interact()

output :
ospf>

But in this case, i want in one console router one can open and on
other console ospf should open. But this i want to do is through one
script only.

Regds
Vik

-- 
http://mail.python.org/mailman/listinfo/python-list


Assertion in Python

2006-10-05 Thread vmalhotra
Hi All,

I want to do verification in my scripts. So for that what i am doing
here are shown below:

1. Telnet to one router.
2. Configure router.
3. Configure routing.

Now after doing all these i have to check showinterfaces. So i execute
command show interface and saved the output in one file.

Now the problem which i am facing is how to do assertion from that
output. e.g output is something like this

eth0 is up
  OSPF not enabled on this interface
eth1 is up
  Internet Address 192.168.1.2/24, Area 0.0.0.0
  Router ID 192.168.1.2, Network Type BROADCAST, Cost: 10
  Transmit Delay is 1 sec, State DR, Priority 1
  Designated Router (ID) 192.168.1.2, Interface Address 192.168.1.2
  No backup designated router on this network
  Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
Hello due in 00:00:00
  Neighbor Count is 0, Adjacent neighbor count is 0
eth2 is up
  OSPF not enabled on this interface
eth3 is down
  OSPF not enabled on this interface
lo is up
  OSPF not enabled on this interface
sit0 is down
  OSPF not enabled on this interface

In this i want to check Designated Router (ID) 192.168.1.2.

If this is the same Ip which i have gice in configuration then test
case will get pass otherwise Fail.

Can somebody send me the code how to do this.

Thanks in Advance
Vikram Malhotra

-- 
http://mail.python.org/mailman/listinfo/python-list