DuncanM Posted November 13, 2006 Share Posted November 13, 2006 I'm looking to automate a telnet session, specifically to log into and send commands to a Cisco device. What would be the best way to go about this with AutoIT (or suggestions if there's a better solution)? I was going to write it in Python, but the library I needed (pexpect) does not work properly in Windows because of a pty requirement.. Thanks Link to comment Share on other sites More sharing options...
Schatten Posted November 13, 2006 Share Posted November 13, 2006 (edited) if you only want to sent commands with telnet then i could write you a little script ^^ you only would have to answer me two questions 1. which commands should be sent? 2. what is a cisco device? ^^ Edited November 13, 2006 by Schatten Link to comment Share on other sites More sharing options...
MadBoy Posted November 13, 2006 Share Posted November 13, 2006 if you only want to sent commands with telnet then i could write you a little script ^^you only would have to answer me two questions1. which commands should be sent?2. what is a cisco device? ^^@Shatten: cisco device is switch or router or any other network device produced by Cisco. It's world known manufacturer. The point of Telnet is to have it working both ways i guess. Doing it only one way will give no usable stuff from automation. At least not what it could be done with it My little company: Evotec (PL version: Evotec) Link to comment Share on other sites More sharing options...
DuncanM Posted November 13, 2006 Author Share Posted November 13, 2006 if you only want to sent commands with telnet then i could write you a little script ^^you only would have to answer me two questions1. which commands should be sent?2. what is a cisco device? ^^Actually I'm going to need to not only send commands, but also read the output generated by the telnet session (for example, when the string "Password" appears, send the password). Link to comment Share on other sites More sharing options...
rbhkamal Posted November 13, 2006 Share Posted November 13, 2006 Actually I'm going to need to not only send commands, but also read the output generated by the telnet session (for example, when the string "Password" appears, send the password).May I ask how you are going to do it?RK "When the power of love overcomes the love of power, the world will know peace"-Jimi Hendrix Link to comment Share on other sites More sharing options...
DkReaver Posted November 13, 2006 Share Posted November 13, 2006 (edited) Actually I'm going to need to not only send commands, but also read the output generated by the telnet session (for example, when the string "Password" appears, send the password).I am not familiar enough with AutoIT to comment on its suitability for this application, but I am aware of several alternatives designed for this application.I am assuming that you want general purpose scripting ability for Cisco router telnet sessions, and I try to address that with the options below. If you have a specific goal, like backing up your configs, there are tools and pre-written scripts aimed at those specific automation tasks.Commercial products:http://www.net-sense.com - Router scripting suitehttp://www.solarwinds.net - Various router tools, but likely not exactly what you are looking for.Open Source/Free:TCL:http://www.cisco.com/en/US/products/sw/ios...00801a75a7.htmlhttp://www.oreillynet.com/pub/a/mac/2001/1...router_tcl.htmlSNMP:http://www.pancho.orgGrab-bag:http://cosi-nms.sourceforge.net/related.htmlAn end run on this would be using a scriptable terminal emulator:WRQ Reflectionshttp://www.wrq.comBest --Kirk Edited November 13, 2006 by DkReaver Link to comment Share on other sites More sharing options...
AzKay Posted November 13, 2006 Share Posted November 13, 2006 Might want to look at the TCP commands? Mainly TCPSend(). # MY LOVE FOR YOU... IS LIKE A TRUCK- # Link to comment Share on other sites More sharing options...
rbhkamal Posted November 14, 2006 Share Posted November 14, 2006 Might want to look at the TCP commands? Mainly TCPSend().Probably looking at msdn for some dlls would be faster, no? "When the power of love overcomes the love of power, the world will know peace"-Jimi Hendrix Link to comment Share on other sites More sharing options...
AzKay Posted November 14, 2006 Share Posted November 14, 2006 (edited) Probably looking at msdn for some dlls would be faster, no?I dont think so. EDIT:: This seems like easier than looking up a dll. TCPStartup() $Socket = TCPConnect("0.0.0.0", 23) TCPSend($Socket, "Wow!, Im talking on telnet! Sending commands!!!!") Edited November 14, 2006 by AzKay # MY LOVE FOR YOU... IS LIKE A TRUCK- # Link to comment Share on other sites More sharing options...
Schatten Posted November 14, 2006 Share Posted November 14, 2006 (edited) the tcp "conversation" could look like this:cisco device asks for loginname autoit script sends the loginnamecisco device asks for password autoit script sends the passwortcisco device waits for commands autoit script sends a commandautoit script waits for results cisco device sends resultsclose connectionif the cisco device follows this system we only have to translate it to autoit DuncanM it would be the best if you post an example of a telnet session with your cisco device Edited November 14, 2006 by Schatten Link to comment Share on other sites More sharing options...
rbhkamal Posted November 14, 2006 Share Posted November 14, 2006 (edited) I dont think so. EDIT:: This seems like easier than looking up a dll. TCPStartup() $Socket = TCPConnect("0.0.0.0", 23) TCPSend($Socket, "Wow!, Im talking on telnet! Sending commands!!!!") lol .. I didn't think it's that easy. Edit:I will give it a test. Does anyone know of an open telnet on the internet? Edited November 14, 2006 by rbhkamal "When the power of love overcomes the love of power, the world will know peace"-Jimi Hendrix Link to comment Share on other sites More sharing options...
Schatten Posted November 14, 2006 Share Posted November 14, 2006 there are many telnet games on the internet here is one: server: void.dune.net Port: 3000 Link to comment Share on other sites More sharing options...
Zedna Posted November 14, 2006 Share Posted November 14, 2006 For AutoIt & Telnet look here Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Schatten Posted November 15, 2006 Share Posted November 15, 2006 An extra telnet programm is not necessary. You only have to youse the TCPSend () and TCPRecv () function. Link to comment Share on other sites More sharing options...
DuncanM Posted November 17, 2006 Author Share Posted November 17, 2006 An extra telnet programm is not necessary.You only have to youse the TCPSend () and TCPRecv () function.Sorry, I was out for a few days - thanks for the responses. Anyways, how would I use TCPRecv in this case? Say, for example, I want to wait for the device to return the string "I am returning a string" before sending the command "command" - how would this work? Link to comment Share on other sites More sharing options...
Schatten Posted November 17, 2006 Share Posted November 17, 2006 (edited) Sorry, I was out for a few days - thanks for the responses. Anyways, how would I use TCPRecv in this case? Say, for example, I want to wait for the device to return the string "I am returning a string" before sending the command "command" - how would this work? you can do this: while 1 $RECVVAR = TCPRecv ( SOCKET ) if $RECVVAR <> "" then exitloop wend Edited November 17, 2006 by Schatten Link to comment Share on other sites More sharing options...
Frank_O Posted December 15, 2006 Share Posted December 15, 2006 Hello Duncan, I like autoit, but for scipting telnet-sessions to cisco-devices I am using TTERMPRO. I attached 2 examples (rename them to *.TTL). Frankshow_int.txtclear_ifcounter.txt Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now