#27964 - 2002-08-28 03:41 PM
Send Data via Telnet with Kix
|
Jacks0r
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
|
|
|
|
#27967 - 2002-08-28 04:46 PM
Re: Send Data via Telnet with Kix
|
Jacks0r
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
   
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
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
|
|
|
|
#27971 - 2002-08-29 11:44 AM
Re: Send Data via Telnet with Kix
|
Jacks0r
Fresh Scripter
Registered: 2002-05-28
Posts: 23
Loc: Berlin, Germany
|
It's myterious. The window gets the focus...and then happens nothing..... [ 29. August 2002, 11:45: Message edited by: Jacks0r ]
|
|
Top
|
|
|
|
#27973 - 2002-08-29 01:20 PM
Re: Send Data via Telnet with Kix
|
Jacks0r
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
   
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
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
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
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 702 anonymous users online.
|
|
|