Page 1 of 1 1
Topic Options
#137665 - 2005-04-11 09:12 AM Control a telnet session with kix
mima Offline
Hey THIS is FUN

Registered: 2002-01-25
Posts: 217
Loc: Jönköping, Sweden
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

Top
#137666 - 2005-04-11 09:24 AM Re: Control a telnet session with kix
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
Not from KiXtart directly however some utility by Howard Bullock might be able to handle it.

Not sure if KiXform is ready for that or not but I'm sure both Howard and Shawn (KiXforms author) will post something more about it soon.

Top
#137667 - 2005-04-11 09:42 AM Re: Control a telnet session with kix
mima Offline
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 Offline
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 Offline
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
#137670 - 2005-04-11 03:40 PM Re: Control a telnet session with kix
mima Offline
Hey THIS is FUN

Registered: 2002-01-25
Posts: 217
Loc: Jönköping, Sweden
Bryce
Where can I find how to kix with that dll. I reg the dll in my system but cant find any manual.

/Mima

Top
#137671 - 2005-04-11 03:42 PM Re: Control a telnet session with kix
mima Offline
Hey THIS is FUN

Registered: 2002-01-25
Posts: 217
Loc: Jönköping, Sweden
Found the w3Sockets Reference
It was on the website.

/Mima

Top
#137672 - 2005-04-11 04:21 PM Re: Control a telnet session with kix
mima Offline
Hey THIS is FUN

Registered: 2002-01-25
Posts: 217
Loc: Jönköping, Sweden
Richard H, can you give me an example on how to use AutoItX DLL from one kixscript ?
Dont really understand the syntax ofhow to the call for AutoItX functions inside kix.

/mima

Top
#137673 - 2005-04-11 04:55 PM Re: Control a telnet session with kix
Kdyer Offline
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
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#137674 - 2005-04-11 04:58 PM Re: Control a telnet session with kix
mima Offline
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 Offline
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 Offline
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
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 2220 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.078 seconds in which 0.039 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org