Page 1 of 1 1
Topic Options
#27964 - 2002-08-28 03:41 PM Send Data via Telnet with Kix
Jacks0r Offline
Fresh Scripter

Registered: 2002-05-28
Posts: 23
Loc: Berlin, Germany
Hi,

i would configuring some "HP JetDirect Printservers" with Kix via Telnet.
1. Problem: How to make a Telnet-Connection to a specific IP.
2. Problem: How to send data to the IP.

The data has a format as follows:

"dhcp-config: 0"
"ethertalk: 0"
"ipx/spx: 0"
"dlc/llc: 0"
"host-name: HOSTNAME"
"ip: 10.10.10.20"
"default-gw: 10.10.10.1"
"quit"
(all without quotes)

There is no password or something else.

Any suggestions?
I think, it could be resolved with WSH or VBS.
But how? *g*

Thx

Jacks0r

Top
#27965 - 2002-08-28 03:48 PM Re: Send Data via Telnet with Kix
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
you can figure it with just kix.

if you check my sendmail()-udf, you see me sending mail with telnet.

but to make it happen so the user won't see it...

I think you should check on the wshpipe()-udf...
_________________________
!

download KiXnet

Top
#27966 - 2002-08-28 04:20 PM Re: Send Data via Telnet with Kix
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Don't forget:
0. Problem: How to connect to a JetDirect print server with no IP address...

If the print servers support it and they are on your network, use "arp -s" to update your ARP table before connecting.

If they don't (or they are on another subnet) you will still need to configure the basic network information manually.

Top
#27967 - 2002-08-28 04:46 PM Re: Send Data via Telnet with Kix
Jacks0r Offline
Fresh Scripter

Registered: 2002-05-28
Posts: 23
Loc: Berlin, Germany
Thx for replies.

The Printserver gets an IP via DHCP.
I scan the entire network (respektive printing the status-page) and then i make a telnet-session to that ip an then i'm configuring the PS manually.
So, that costs a lot of time.
My wish is to Enter the Target-IP, enter data in some vars and kix should it send to the PS and quits the session.

Jacks0r

Top
#27968 - 2002-08-28 05:06 PM Re: Send Data via Telnet with Kix
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
If you take a look at Jooel's sendmail UDF you will see a way of doing it using windows telnet and KiXtart "SendKeys()"

There is no feedback, or any way to check if it has worked, but it may be sufficient for your needs.

Top
#27969 - 2002-08-29 10:27 AM Re: Send Data via Telnet with Kix
Jacks0r Offline
Fresh Scripter

Registered: 2002-05-28
Posts: 23
Loc: Berlin, Germany
So, here's the code:

BREAK ON
? "Target-IP: " GETS $server
RUN '%comspec% /c start "Config '+$server+'" /MIN telnet $server'
SLEEP 5
IF SetFocus ("Config "+$server) <> 0
EXIT(53)
ENDIF
SLEEP 5
IF SetFocus ("Config "+$server) <> 0
EXIT(53)
ENDIF
SLEEP 5
SendKeys(@CRLF) SLEEP 1
SendKeys(@CRLF) SLEEP 1
SendKeys("hostname: MOEP" + @CRLF) SLEEP 1
SendKeys("quit" + @CRLF) SLEEP 1

But, Kix doesn't send the keystrokes.
Where's the Error?

Jacks0r

Top
#27970 - 2002-08-29 10:46 AM Re: Send Data via Telnet with Kix
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
/MIN could be one catch...

also, you just exit when no focus:
IF SetFocus ("Config "+$server) <> 0
EXIT(53)
ENDIF

do it little bit more informative:
IF SetFocus ("Config "+$server) <> 0
"error occured: @serror" EXIT @error
ENDIF

this way, you will see what the error is...
_________________________
!

download KiXnet

Top
#27971 - 2002-08-29 11:44 AM Re: Send Data via Telnet with Kix
Jacks0r Offline
Fresh Scripter

Registered: 2002-05-28
Posts: 23
Loc: Berlin, Germany
It's myterious. [Smile]
The window gets the focus...and then happens nothing.....

[ 29. August 2002, 11:45: Message edited by: Jacks0r ]

Top
#27972 - 2002-08-30 12:23 AM Re: Send Data via Telnet with Kix
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
does kix end?
do you hear beeps?

if you enabled my last error check, do you get anything on the kix-screen?

also, your script has pretty much sleep for nothing.

SLEEP 5
IF SetFocus ("Config "+$server) <> 0
EXIT(53)
ENDIF
SLEEP 5
IF SetFocus ("Config "+$server) <> 0
EXIT(53)
ENDIF
SLEEP 5

it sleeps 15 seconds before sending anything and the other check is just the same as the first one.
you can reduce it to:
SLEEP 5
IF SetFocus ("Config "+$server) <> 0
EXIT(53)
ENDIF
SLEEP 5

also, having sleeps of 5 seconds is not wise.
so:
SLEEP 2
IF SetFocus ("Config "+$server) <> 0
EXIT(53)
ENDIF

would be more appropiate.
_________________________
!

download KiXnet

Top
#27973 - 2002-08-29 01:20 PM Re: Send Data via Telnet with Kix
Jacks0r Offline
Fresh Scripter

Registered: 2002-05-28
Posts: 23
Loc: Berlin, Germany
There's no "Beep"
The Kixscript ends normal and the Telnet-window stays open.
The SLEEP-Orders i've taken from the sendmail()-udf.

[ 29. August 2002, 13:21: Message edited by: Jacks0r ]

Top
#27974 - 2002-08-29 01:26 PM Re: Send Data via Telnet with Kix
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Try this. I've written it on a Win95 box, but the telnet client for NT4 should be the same.

This script will record a log session. At the moment I just display it using notepad, but of course you can read the log file in and check it automatically.

If you are using the console telnet rather than the GUI version, then of course it won't work [Frown]

code:
BREAK ON

$sLogFile=%TEMP%+"\telnet.log"

Function udfSend($sTextToSend,Optional $iSleep)

If SetFocus("Telnet")
"Cannot set focus!" ?
"Reason: @ERROR @SERROR"
Quit @ERROR
EndIf
If SendKeys($sTextToSend)
"Cannot send data!"
"Reason: @ERROR @SERROR"
Quit @ERROR
EndIf

If Val($iSleep) Sleep Val($iSleep) EndIf

EndFunction

Function udfConfigServer($sServer)
RUN '%comspec% /c start telnet $sServer'
SLEEP 5
; Start logging...
udfSend("~TL"+$sLogFile+@CRLF)
; Wake up session...
udfSend(@CRLF,1)
udfSend(@CRLF,1)
; Send configuration data...
udfSend("hostname: MOEP" + @CRLF,1)
; Close client end...
udfSend("quit" + @CRLF,1)
; Shut down logging...
udfSend("~TS")
; Close telnet application...
udfSend("~{F4}")
; Display results:
Shell "%COMSPEC% /C notepad.exe " + $sLogFile
EndFunction

While "True"
"Enter server name or null to exit: " GetS $sServer
If $sServer = "" Exit 0 EndIf
udfConfigServer($sServer)
Loop


Top
#27975 - 2002-08-29 02:54 PM Re: Send Data via Telnet with Kix
Jacks0r Offline
Fresh Scripter

Registered: 2002-05-28
Posts: 23
Loc: Berlin, Germany
Thx Richard,
it seems that it works with the Console-Client. (no error-messages).
But the the data wasn't send and the log-file wasn't created.

Jacks0r

Top
#27976 - 2002-08-29 06:35 PM Re: Send Data via Telnet with Kix
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
mmm...

if there is no beep (sendkey makes one for me when sending keys to nowhere...) and no messages given, I quess it's time to check the script again.

what comes to sendmail, I sure have to correct the syntax. I was just starting to play with sendkeys at the time...
_________________________
!

download KiXnet

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 641 anonymous users online.
Newest Members
fgarcia, Viginette, ManuvdWielNL, Sir_Barrington, batdk82
17889 Registered Users

Generated in 0.071 seconds in which 0.038 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