[Xorp-users] Problem
Atanu Ghosh
atanu@ICSI.Berkeley.EDU
Thu, 16 Jun 2005 14:00:14 -0700
Hi,
The following works for me but its not elegant:
----------------------------------------
#!/usr/bin/env python
import time
import sys
import pexpect
child=pexpect.spawn ('xorpsh')
child.expect('Xorp> ')
child.send('show ')
time.sleep(1)
# Defeat the command line completion.
child.sendline(' igmp group | no-more')
time.sleep(1)
child.sendeof()
while 1:
line = child.readline()
if not line:
break
print line,
child.close()
----------------------------------------
Atanu.
>>>>> "zze-BEN" == zze-BEN SAID Mehdi <RD-CORE-ISS" <mehdi.bensaid@rd.francetelecom.com>> writes:
zze-BEN> I tried this out, but T still got nothing... I just need a
zze-BEN> way to redirect the result of this command in a
zze-BEN> file...that's it. Please, any ideas? Thanks
zze-BEN> -----Message d'origine----- De : Pavlin Radoslavov
zze-BEN> [mailto:pavlin@icir.org] Envoyé : mercredi 15 juin 2005
zze-BEN> 19:26 À : zze-BEN SAID Mehdi RD-CORE-ISS Cc :
zze-BEN> xorp-users@xorp.org; Pavlin Radoslavov;
zze-BEN> atanu@ICSI.Berkeley.EDU Objet : Re: [Xorp-users] Problem
>> Hi everybody, I have a little problem. I'm trying to get
>> information from Xorp using a pexpect python script:
>>
>> #!/usr/bin/env python import sys import pexpect
>>
>> child=pexpect.spawn ('xorpsh') child.expect('Xorp> ')
>> child.sendline ('show igmp group') child.expect('Xorp> ') print
>> child.before # I use this to print the result of the show command
>> child.close()
>>
>> Everything's works right, but I got nothing displayed!!! And of
>> course, when I type it manually on the xorpsh CLI, there are so
>> many routes. Is there any solution?
zze-BEN> Does it work for commands like "show igmp interface" that
zze-BEN> eventually would display much shorter output?
zze-BEN> One possible problem that comes to mind if the output is so
zze-BEN> long, is that probably it goes through the xorpsh built-in
zze-BEN> pager. To verify that, try to disable the pager by using
zze-BEN> the following command inside your python script: show igmp
zze-BEN> group | no-more
zze-BEN> Pavlin