[Tutor] Telnet to Router/Switch
Shahjehan Hakim
shahjehan_hakim at hotmail.com
Mon Dec 24 19:19:37 CET 2007
Hi everyone..
I have to make Telnet session with Router/switch of Cisco. Anybody has idea how it can be done? from what i researched, i got most of the telnet session like client/servers. But what I have to do here is just to create a Telnet session which writes the password when its prompted and then write the commands and fetch the result which is returned by the session.
> From: tutor-request at python.org> Subject: Tutor Digest, Vol 46, Issue 60> To: tutor at python.org> Date: Mon, 24 Dec 2007 12:00:06 +0100> > Send Tutor mailing list submissions to> tutor at python.org> > To subscribe or unsubscribe via the World Wide Web, visit> http://mail.python.org/mailman/listinfo/tutor> or, via email, send a message with subject or body 'help' to> tutor-request at python.org> > You can reach the person managing the list at> tutor-owner at python.org> > When replying, please edit your Subject line so it is more specific> than "Re: Contents of Tutor digest..."> > > Today's Topics:> > 1. Re: Output of list (J?nos Juh?sz)> 2. Re: Output of list (Martin Walsh)> 3. Re: Output of list (J?nos Juh?sz)> 4. Re: Output of list (Martin Walsh)> 5. Py2Exe Tutorial (TW)> > > ----------------------------------------------------------------------> > Message: 1> Date: Sun, 23 Dec 2007 17:52:28 +0100> From: J?nos Juh?sz <janos.juhasz at VELUX.com>> Subject: Re: [Tutor] Output of list> To: tutor at python.org> Message-ID:> <OFE1FA4AE3.6B6F711A-ONC12573BA.005C6322-C12573BA.005CB1FC at velux.com>> Content-Type: text/plain; charset="US-ASCII"> > Dear Emil,> > > I want to be capable of converting a string into a list where all > > the items, in the list, have a fixed length not equal to 1 e.g i > > have k = 'abcdefgh' and I want the fixed length for all the the > > items to be 2 then the list would look like ['ab', 'cd', 'ef, 'gh'].> > How do i do this?> > > > > - Emil> > It is nice place to use a generator:> > def pairs(sliceit):> streamlist = list(sliceit)> streamlist.reverse()> while streamlist:> pair = streamlist.pop() > try: pair += streamlist.pop()> except: pass> yield pair> > ## Probably it is easier to understand> def pairs2(sliceit):> try:> while sliceit:> yield sliceit[:2]> sliceit = sliceit[2:]> except: # oops, it was odd length> yield sliceit> > > print '_'.join(e for e in pairs('abcd'))> print '_'.join(e for e in pairs('abcde'))> print '_'.join(e for e in pairs2('abcd'))> print '_'.join(e for e in pairs2('abcde'))> > > Best Regards,> Janos> > > ------------------------------> > Message: 2> Date: Sun, 23 Dec 2007 13:40:13 -0600> From: Martin Walsh <mwalsh at groktech.org>> Subject: Re: [Tutor] Output of list> Cc: tutor at python.org> Message-ID: <476EB99D.7050200 at groktech.org>> Content-Type: text/plain; charset=UTF-8> > J?nos Juh?sz wrote:> > It is nice place to use a generator:> > > > def pairs(sliceit):> > streamlist = list(sliceit)> > streamlist.reverse()> > while streamlist:> > pair = streamlist.pop() > > try: pair += streamlist.pop()> > except: pass> > yield pair> > > > ## Probably it is easier to understand> > def pairs2(sliceit):> > try:> > while sliceit:> > yield sliceit[:2]> > sliceit = sliceit[2:]> > except: # oops, it was odd length> > yield sliceit> > > > ... Or, by extending Alan's solution ...> > def splitStringByN(s, n):> for m in range(0, len(s), n):> yield s[m:m+n]> > k = 'abcdefghi'> list(splitStringByN(k, 2))> > As it turns out, this is similar to an ASPN Cookbook recipe contributed> by Dmitry Vasiliev:> http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/302069> > HTH,> Marty> > > ------------------------------> > Message: 3> Date: Sun, 23 Dec 2007 21:09:10 +0100> From: J?nos Juh?sz <janos.juhasz at VELUX.com>> Subject: Re: [Tutor] Output of list> To: tutor at python.org> Message-ID:> <OF80477711.889289C7-ONC12573BA.006DC596-C12573BA.006EB3EB at velux.com>> Content-Type: text/plain; charset="US-ASCII"> > Dear Marty,> > > >... Or, by extending Alan's solution ...> >> >def splitStringByN(s, n):> > for m in range(0, len(s), n):> > yield s[m:m+n]> >> >k = 'abcdefghi'> >list(splitStringByN(k, 2))> > It seems to be the most readable solution for me.> > > >As it turns out, this is similar to an ASPN Cookbook recipe contributed> >by Dmitry Vasiliev:> >http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/302069> >> >HTH,> >Marty> > Thanks for the link.> > > Best regards,> Janos> > > ------------------------------> > Message: 4> Date: Sun, 23 Dec 2007 14:53:43 -0600> From: Martin Walsh <mwalsh at groktech.org>> Subject: Re: [Tutor] Output of list> To: tutor at python.org> Message-ID: <476ECAD7.1030203 at groktech.org>> Content-Type: text/plain; charset=UTF-8> > J?nos Juh?sz wrote:> > Dear Marty,> > Hi Janos,> > >> ... Or, by extending Alan's solution ...> >>> >> def splitStringByN(s, n):> >> for m in range(0, len(s), n):> >> yield s[m:m+n]> >>> >> k = 'abcdefghi'> >> list(splitStringByN(k, 2))> > > > It seems to be the most readable solution for me.> > For completeness, one could also pull it out of the function def and use> a generator expression directly. If I'm not mistaken, this would be more> or less equivalent:> > k = 'abcdefghi'> list((k[m:m+2] for m in range(0, len(k), 2)))> > > > > > >> As it turns out, this is similar to an ASPN Cookbook recipe contributed> >> by Dmitry Vasiliev:> >> http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/302069> >>> >> HTH,> >> Marty> > > > Thanks for the link.> > No problem.> > Happy Holidays!> Marty> > > ------------------------------> > Message: 5> Date: Sun, 23 Dec 2007 14:48:54 -0500> From: "TW" <chester_lab at twcny.rr.com>> Subject: [Tutor] Py2Exe Tutorial> To: <tutor at python.org>> Message-ID: <002a01c8459c$df8577e0$0301a8c0 at brucetower>> Content-Type: text/plain; charset="iso-8859-1"> > > I am wondering if there is a good tutorial on Py2Exe and its functions?> I have not been able to find one. I have samples but that is not good> enough. It would be nice to have something explain all the functions for> including directories, modules and all that stuff when making an executable.> > Bruce> > > > ------------------------------> > _______________________________________________> Tutor maillist - Tutor at python.org> http://mail.python.org/mailman/listinfo/tutor> > > End of Tutor Digest, Vol 46, Issue 60> *************************************
_________________________________________________________________
Don't get caught with egg on your face. Play Chicktionary!
http://club.live.com/chicktionary.aspx?icid=chick_wlhmtextlink1_dec
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20071224/5c1b1577/attachment-0001.htm
More information about the Tutor
mailing list