#137667 - 2005-04-11 09:42 AM
Re: Control a telnet session with kix
|
mima
Hey THIS is FUN
Registered: 2002-01-25
Posts: 217
Loc: Jönköping, Sweden
|
I found this on Howard:s webpage Quote:
$oTelnet = $HABObject.Telnet()
but I dont know if this could do the trick..
/Mima
|
|
Top
|
|
|
|
#137668 - 2005-04-11 01:32 PM
Re: Control a telnet session with kix
|
Richard H.
Administrator
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
Quote:
Hi I must script a telnet session to a switch, to download the configuration. The switch does not support ftp. When I am connected trough telnet, it is only some keypress that must be done, single letters. Is this possibly with kix ??
/Mima
You can use AutoIt to control the telnet session, either as the primary scripting language or you can use the AutoItX DLL and control the application from KiXtart if you prefer.
|
|
Top
|
|
|
|
#137669 - 2005-04-11 02:05 PM
Re: Control a telnet session with kix
|
Bryce
KiX Supporter
   
Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
|
These folks, http://www.dimac.net/
have a free dll package that you can use to script a telnet seccion. go to "free downloads" and download the w3Sockets package.
Edited by Bryce (2005-04-11 02:11 PM)
|
|
Top
|
|
|
|
#137673 - 2005-04-11 04:55 PM
Re: Control a telnet session with kix
|
Kdyer
KiX Supporter
   
Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
|
mima,
I believe what Richard is referring to is you can use the DLL that comes with AutoIT and do a CREATEOBJECT to it and then make the necessary calls to AutoIT.
Kent
|
|
Top
|
|
|
|
#137674 - 2005-04-11 04:58 PM
Re: Control a telnet session with kix
|
mima
Hey THIS is FUN
Registered: 2002-01-25
Posts: 217
Loc: Jönköping, Sweden
|
Yes, I am trying. have got this far: Code:
Dim $AutoIt $AutoIt = WScript.CreateObject("AutoItX3.Control") run '%Comspec% /c "Telnet.exe"' ;Shell '%Comspec% /c "Telnet.exe"' $AutoIt.Send "open 172.20.40.48"
but cant get this to work.... it wont write my open command in my telnet session /mima
|
|
Top
|
|
|
|
#137675 - 2005-04-11 05:53 PM
Re: Control a telnet session with kix
|
mima
Hey THIS is FUN
Registered: 2002-01-25
Posts: 217
Loc: Jönköping, Sweden
|
Can anyone give me some ideas what I am doing wrong here...
I have register the dll, made one kix script called telnet.kix. Trying to lanch the script from a command prompt with "kix32.exe telnet.kix".
Here is the code: Code:
$AutoIt = CreateObject("AutoItX3.Control") ; Trying to lanch a telnet session $AutoIt.run "Telnet.exe" $AutoIt.Send "open 172.20.40.48"
Nothing happends, the scripts dont launch telnet, it only prints my command in my command prompts.  /mima
|
|
Top
|
|
|
|
#137676 - 2005-04-12 10:56 AM
Re: Control a telnet session with kix
|
Richard H.
Administrator
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
Well, there is good news and there is bad news.
The good news is that you can control the app. The bad news is that I can't see how to get the text of the console.
Here is a basic working script, but you will probably be better off with the W3Socket collection that Bryce found.
Code:
Break ON $=SetOption("Explicit","ON") $=SetOption("WrapAtEOL","ON") Global $OBJECT $OBJECT=9 Dim $oAutoIT Dim $sRouterIP $sRouterIP="open 172.20.40.48" Dim $sCommand Dim $sTitle $sTitle="AutoTelnet" Dim $iPID ; Create AutoIT object $oAutoIt = CreateObject("AutoItX3.Control") If @ERROR OR VarType($oAutoIt)<>$OBJECT "ERROR: Could not create AutoIt instance"+@CRLF Exit @ERROR EndIf ; Set title matching to allow advanced directives $=$oAutoIt.Opt("WinTitleMatchMode",4) $sCommand="telnet.exe" Run '"'+%COMSPEC%+'" /C START "'+$sTitle+'" '+$sCommand If @ERROR "ERROR: Could not start command"+@CRLF Exit @ERROR EndIf ; Wait for telnet window to appear... If Not CInt($oAutoIt.WinWait($sTitle,"",10)) "ERROR: Telnet process took too long to appear."+@CRLF Exit 1 EndIf sleep 1 $oAutoIt.Send("open "+$sRouterIP+"{ENTER}")
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 1219 anonymous users online.
|
|
|