[Tutor] Python on Windows with SSH for Cisco devices

2007-07-13 Thread Chris Hallman
Has anyone successfully used Python on Windows with SSH connections to Cisco devices? I'm referring to using a Python module (Paramiko, pyssh though not actively developed, Twisted.conch, etc.) and not shelling out via Pexpect (doesn't work on Windows) or Plink. I need to connect to hundreds of Ci

[Tutor] Telnet and special characters

2007-02-27 Thread Chris Hallman
Is it possible to send a F1 "character" over a telnet connection? I've searched but I can't find a solution. I've tried SendKeysand other methods, but I can't get it to work. import telnetlib pswd = "***" host = "***" tn = telnetlib.Telnet(host) tn.rea

[Tutor] telnet read_until problems

2007-02-12 Thread Chris Hallman
I've written a program that tests ISDN dial backup at 1,000 locations. I've broken up the logic into server functions within a threading class (i.e. logon, get interfaces, get dial string, etc.). At 999 locations, the following code extract the first of three dial strings: def GetDialString(se

[Tutor] python24dll not found

2007-02-07 Thread Chris Hallman
My apologies if this isn't the correct forum for such a question, however I was having a problem with Python and couldn't find the cause. I have two systems running Python. My laptop and a server: laptop: WinXP SP2 x86 Python 2.5 pymssql 0.8.0 (for 2.5) pywin32-210 (for 2.5) server: Win2003 no S

[Tutor] problem with telnetlib, threading class and try/except

2007-01-17 Thread Chris Hallman
I'm writing a multithreaded program that initiates a dial backup connection to check the B channels on ISDN BRI connections. I recently added logic to check for offline devices (Operation timed out) and DNS errors (getaddrinfo failed). When it encounters the exception, it doesn't appear to be exit

[Tutor] help with telnet error

2007-01-17 Thread Chris Hallman
I'm working on a program that telnets to multiple devices to test their backup ISDN BRI connections. I'm trying to build in error recovery with try/except logic, but I'm having trouble getting it to work. This first example uses a host name that isn't in our DNS (yes, this does happen): import t

[Tutor] dictionary manipulation

2006-07-26 Thread Chris Hallman
I need some suggestions on how to work with a dictionary. I've got a program that builds a dictionary. I need to be able to manipulate the different keys and data so that I can write the output to a file AND utilize the smtplib to send the data in an email. I had problems using the data in the dict

Re: [Tutor] TypeError: 'str' object is not callable

2006-02-17 Thread Chris Hallman
Oh, gee. Do I feel sheepish. I knew I had been staring at the error all along, but yet couldn't see it.Thanks!!On 2/17/06, Kent Johnson <[EMAIL PROTECTED]> wrote:Chris Hallman wrote: >> Here is my script:> input = file(rpath, "r")> for line in file(rpath):> for file in dirList:>   

[Tutor] TypeError: 'str' object is not callable

2006-02-17 Thread Chris Hallman
Here is my script:send_file.pyimport os, random, re, string, sys, telnetlib, threading, timefrom time import strftimefrom threading import Threadclass ConfigIT(threading.Thread):     def __init__(self,host):        Thread.__init__(self)        self.host = host        self.filename = filename    def

Re: [Tutor] threading issues

2005-10-25 Thread Chris Hallman
the hosts in the input file are sorted alphabetically but my results were output out of order?! (possibly due to latency in PING responses or some latency in the thread joining; not sure of either). I had to do the crude temp output file so that I could sort the results, but it works!!  On 10

Re: [Tutor] threading issues

2005-10-23 Thread Chris Hallman
t;) + "\n") output.flush() threads = [] for rtr in file(rpath):     thread = PingThread()     thread.start()     threads.append(thread) for thread in threads:     thread.join() print fc    # for debugging output.write(fc + " failures found.\n") output.write("\n" + &qu

[Tutor] threading issues

2005-10-22 Thread Chris Hallman
I hacked together my first script to learn threading. I'm seeing some weird output. This script will PING approximately 1,000 routers. I added a few print commands for debugging so I can see if it runs faster than a single threaded script. It blazes through the routers, however I'm seeing multip

Re: [Tutor] script question

2005-10-18 Thread Chris Hallman
        os.system(r"d:\tnd\bin\cawto.exe -cat NetNet -n l17aesm1 forward red held %s" % (" ".join(sys.argv[1:5]),))         break Again, thank you all for your input. I greatly appreciated it Let me know if you have any further suggestions. On 9/30/05, Kent Johnson <

[Tutor] script to change device configuration

2005-10-18 Thread Chris Hallman
I created a script that parses a directory, strips the ".txt" extension off the file, telnet & log on to the device (the filename is the device name), opens the associated ".txt" file, sends all the commands containted in the file to the device and then executes some commands to save the changes.

Re: [Tutor] script question

2005-09-28 Thread Chris Hallman
Thanks for all the input!!! I really appreciate it. I need to post a correction to my script. What I sent was an early version. I made a few minor modifications: import ConfigParser, string, sys, ossection = sys.argv[1]interface = sys.argv[3]INI=ConfigParser.ConfigParser()INI.read("c:\utils\int

[Tutor] script question

2005-09-26 Thread Chris Hallman
I needed a script that takes command line arguments, searches an ini file for a match to the arguments and then executes a Windows executable. This is my first script using python so I wanted to make sure I made the most of the language. I took bits and pieces from different tutorials and examples