Page 4 of 4 <1234
Topic Options
#97604 - 2003-01-22 03:36 PM Re: is there a "RemoteComputerFromUser" UDF out there
Rocco Capra Offline
Hey THIS is FUN
*****

Registered: 2002-04-01
Posts: 380
Loc: Mansfield Ohio
Ok I got around the "ENTER" key problem in my form...

Function in '_disc.html' to output to temp file...
code:
function ok.onclick()
{
window.returnValue = discription.value+
"\n[HelpDesk]\ncubenum="+cubenum.value+
"\njacknum="+jacknum.value;
window.close();
}

What the output file looks like...
code:
This is a test of the new loop

I wonder what the output will look like?

Thanks,
Rocco
[HelpDesk]
cubenum=Test1
jacknum=Test2

What the kix script loks like...
code:
WHILE((ReadProfileString('$DISCFILE','HelpDesk','cubenum')='')OR
(ReadProfileString('$DISCFILE','HelpDesk','jacknum')=''))
SHELL '%COMSPEC% /c kixwin "file://'+@CURDIR+'\_disc2.html" > "'+$DISCFILE+'"'
$RC=Open(1,'$DISCFILE',2)
$DISC=ReadLine(1)
WHILE((@ERROR=0)AND(ReadLine(1)<>'[HelpDesk]'))
$DISC = $DISC+@CRLF+ReadLine(1)
LOOP
$RC=Close(1)
?$DISC
LOOP

This is what the compiled $DISC looks like...
code:
This is a test of the new loop

I wonder what the output will look like?

Thanks,
Rocco

What do ya think??

Rocco

{edit}
I think the board stripped out all of my @CRLF's in the [ code ] tags. [Frown] There should be some line breaks in there.
{edit}
_________________________
I Love this board!! -------------------- My DEV PC is running KIX 4.22 WINXP Pro

Top
#97605 - 2003-02-05 01:56 AM Re: is there a "RemoteComputerFromUser" UDF out there
JimRobinson Offline
Fresh Scripter

Registered: 2003-01-10
Posts: 42
Loc: Tempe, AZ
I'm not sure if this still belongs here, but here
is a KiXtart solution to Rocco's RemoteComputerFromUser question.
I don't know if this would be a good one to turn
into a UDF, but I do think it could make a nice
little KiXform.

And I probably redid someone else's work with the
InStrArray() UDF, based as it is on jpols
variation of sealeopard's IsInArray(). But I
really needed to find partial string matches,
AScan and IsInArray matched only full strings, and
I couldn't find anything else.

Please post improvements, as I am sure there are
several.

code:
  
;locate.kix
;Queries WINS for a supplied username and if found
;attempts to resolve it to a hostname.
;
;Requirements
;A functioning WINS environment.
;Windows 2000 or XP (not tested on any other OS).
;winscl.exe from the Windows 2000 Resource Kit.
;winsrpc.dll from a Windows 2000 server. Both in your path.
;the UDFs WshPipe()
;and InStrArray()
;
;Usage
;kix32 locate.kix $user="username"
;or a batch file like this:
;
;@echo off
;if "%1"=="" (
; call :usage) else (
; kix32.exe %0\..\locate.kix $user=%1
;)
;GoTo :eof
;
;:usage
;echo/Usage: Locate username
;GoTo :eof

;Set some variables.
break on
$WINSserver = "YOUR_WINS_SERVER_ADDRESS_HERE"
$ShortOffset = Len($WINSserver)
$LongOffset = ($ShortOffset+25)
$file = "%0\..\winscl.txt"
$IP="Not Found"
del $file

;Write the command file used by winscl.exe and output the username
$X = open (1, "$file", 5)
$X = writeline(1, "$WINSserver" + @CRLF)
$X = writeline(1, "QN" + @CRLF)
$X = writeline(1, "$user" + @CRLF)
$X = writeline(1, "1" + @CRLF)
$X = writeline(1, "03" + @CRLF)
$X = writeline(1, "0" + @CRLF)
$X = writeline(1, "EX" + @CRLF)
cls
"Username: " $user ?

;Populate $WINSArray with the results of winscl.exe
;Assign the variables holding the offset to the record in WINSArray
;containing the IP address, if it exists. Output the IP or Not Found.
$WINSarray=WshPipe("%comspec% /c winscl.exe T NOME< winscl.txt",1)
$X = InStrArray("Address is (", $WINSarray)
$Y = InStrArray("Member is (", $WINSarray)
Select
Case $X <> -1
$SrchLen = (LEN($WINSarray[$x])-($ShortOffset+1))
$IP = SubStr($WINSarray[$x],$ShortOffset, $SrchLen )
"Has IP: " $IP ?
Case $Y <> -1
$SrchLen = (LEN($WINSarray[$y])-($LongOffset+1))
$IP = SubStr($WINSarray[$y],$LongOffset, $SrchLen )
"Has IP: " $IP ?
Case 1
"Was Not Found in WINS" ?
EndSelect

;Resolve the hostname using ping -a. Output the hostname or Not Found.
$HostArray = WshPipe("%comspec% /c ping -a -n 1 $IP",1)
$X = InStrArray("Pinging", $HostArray)
if $X <> -1
$YArray = Split($HostArray[1],"")
if $YArray[1] = $IP
"On Host: Not Resolved" ?
else
"On Host: " $YArray[1] ?
endif
else
"Hostname Not Found in WINS" ?
endif
exit


;function InStrArray($string, $array)
;Looks for $string in $array using InStr()
;
;Returns the offset or -1 is not found.

function InStrArray($string, $array)
if vartype($array) >= 8192
for $i = 0 to ubound($array)
if instr($array[$i],$string)
$InStrArray = $i
return
endif
next
endif
$InStrArray = -1
return
endfunction

;
;Function WshPipe()
;
;Author Christopher Shilt (christopher.shilt@relizon.com)
;
;Version 1.1
;
;Version History
;
; 14 June 2002 Version 1.1
; Removed ReadAll Function and incorporated it into WshPipe. Added
; $WshErrorMsg to return the actual error message generated by the
; shelled command.
;
; 14 June 2002 Version 1.0
;
;Action Performs a shell-like command and pipes the output to an array and returns the
; exitcode of the command to the @error macro.
;
;Syntax WshPipe(COMMAND, optional NOECHO)
;
;Parameters
; COMMAND : REQUIRED. The "shell" command you want to perform.
;
; NOECHO : OPTIONAL. Suppress the command's output to the screen, ouput
; is still stored in an array.
;
;Remarks
;
;
;Returns Output of shell command in an array, exitcode of the command in the @error
; macro, and the error message of the command to $WshErrorMsg. By default, the output
; is echoed to the screen but can be suppressed.
;
;Dependencies KiX 4.02
; WSH 5.6 (Included with Microsoft Internet Explorer 6.0. Also available for download
; from Microsoft's MSDN website.)
;
;Example:
; ; Display all KiX files in C:\ directory:
; $rc=WshPipe("%comspec% /c dir c:\*.kix")
; ? "Exit Code: " @error " " $WshErrorMsg
;
; ; Display all KiX files in C:\ directory, but suppress output to screen:
; $rc=WshPipe("%comspec% /c dir c:\*.kix",1)
; ? "Exit Code: " @error " " $WshErrorMsg
;
; ; Display all KiX files in C:\ directory, suppress output to screen. Then use FOR/NEXT
; ; to exclude data.
; $rc=WshPipe("%comspec% /c dir c:\*.kix",1)
; for each $line in $rc
; if not instr($line, "File Not Found")
; ? $line
; endif
; next
; ? "Exit Code: " @error " " $WshErrorMsg
;
;Source
Function WshPipe($ShellCMD, OPTIONAL $NoEcho)
Dim $WshShell, $oExec, $AllOutput, $Exit, $WshExitCode
$WshErrorMsg=""
$WshShell=CreateObject("WScript.Shell")
$oExec=$WshShell.Exec($ShellCMD)
While $Exit<>1
Dim $Output
Select
Case Not $oExec.StdOut.AtEndOfStream
$Output=$oExec.StdOut.ReadAll
Case Not $oExec.StdErr.AtEndOfStream
$Output=$oExec.StdErr.ReadAll
$WshErrorMsg = $Output
Case 1
$Output=-1
EndSelect
If $Output=-1
If $oExec.Status=1
$Exit=1
Endif
Else
If $NoEcho<>1
? $Output
Endif
$AllOutput = $AllOutput + $Output
Endif
Loop
$WshExitCode=$oExec.ExitCode
$WshPipe=split($AllOutput,chr(10))
Exit($WshExitCode)
EndFunction

Jim
_________________________
Jim
--------------------

Top
#97606 - 2003-03-14 11:15 PM Re: is there a "RemoteComputerFromUser" UDF out there
Schuliebug Offline
Hey THIS is FUN
*****

Registered: 2002-01-18
Posts: 379
Loc: Netherlands
Of great help. Downloaded the winsrpc.dll from a W2K server, placed in in the same directory as Winscl.exe and it works on WXP/W2K. Via this way & nbtstat -a with the found IP-number, the workstation can be retrieved.
_________________________
Kind regards,

Top
Page 4 of 4 <1234


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

Who's Online
0 registered and 837 anonymous users online.
Newest Members
M_Moore, BeeEm, min_seow, Audio, Hoschi
17883 Registered Users

Generated in 0.029 seconds in which 0.014 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