Page 1 of 1 1
Topic Options
#76845 - 2003-09-23 05:50 PM Ready ?
KiXrookie Offline
Fresh Scripter

Registered: 2003-09-19
Posts: 19
Can you please take a look at my script before I release? I wanted to use PPING to query any valid IPs on the Network and then use this script against the live workstations without them having to re-login. I started getting a headache so I finally conceded to putting this in the login script for the next time they login.

[CODE]

;This script will get the IP Address and version of Netware from a workstation then write it to a network share

Break on

;Get Cadre Version#
$Netware=ReadValue("HKEY_LOCAL_MACHINE\SOFTWARE\Novell","CurrentVersion")

;Get ComputerName
$computer=ReadValue("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName","ComputerName")

; First octet (169)...
$IP1 = LTRIM(SUBSTR(@IPADDRESS0, 1, 3))
; Second octet (54)...
$IP2 = LTRIM(SUBSTR(@IPADDRESS0, 5, 3))
; Third octet (88)...
$IP3 = LTRIM(SUBSTR(@IPADDRESS0, 9, 3))
; Fourth octet (1)...
$IP4 = LTRIM(SUBSTR(@IPADDRESS0, 13, 3))

; Show the 4 octets...
;? $IP1
;? $IP2
;? $IP3
;? $IP4

; Create MyIP from IP Address + Netware Version + ComputerName
$MyIP=$IP1 + "." + $IP2 + "." + $IP3 + "." + $IP4 + " " + $Netware + " " + $computer
;? $MyIP

;Check if MyIP already exists in ipadds.txt

shell '%comspec% /c find /i /c "$MyIP" "c:\kixtart\ipadds.txt"'
If @error = 0 goto end
else
RedirectOutput ("X:\kixtart\ipadds.txt") = 0
? $MyIp
endif

:end

Top
#76846 - 2003-09-23 05:51 PM Re: Ready ?
KiXrookie Offline
Fresh Scripter

Registered: 2003-09-19
Posts: 19
PS- I'll change the location of the results to a network share once it's ready to go.
Top
#76847 - 2003-09-23 05:55 PM Re: Ready ?
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11162
Loc: Boston, MA, USA
Please read the TCP/IP primer in the FAQ Forum and use the IsStringInFile() UDF instead. Use the @WKSTA instead of a registry read.
_________________________
There are two types of vessels, submarines and targets.

Top
#76848 - 2003-09-23 07:40 PM Re: Ready ?
KiXrookie Offline
Fresh Scripter

Registered: 2003-09-19
Posts: 19
The @wksta and @ipaddress0 definitley makes it cleaner. I'm a little confused about using the IsStringInFile UDF as part of the script though.

Would the $filename=ipaddress0 and the $string=c:\kixtart\ipadds.txt

[CODE]

function IsStringInFile($filename,$string)

$isstringinfile=0 if $string=''
exit 87
endif

if not exist($filename)
exit 2
endif

shell '%COMSPEC% /e:1024 /c find /c /i "'+$string+'" "'+$filename+'" > nul'
if @ERROR=0
$IsStringInFile=1
endif
exit 0

endfunction

Top
#76849 - 2003-09-23 07:54 PM Re: Ready ?
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11162
Loc: Boston, MA, USA
You'd use it to check whether the IP address is already in that file.

However, a .INI file with READPROFILESTRING/WRITEPROFILESTRING would be even more efficient as you'd do only one line to check whehter the IP address is already present, then a second line to write the IP address. Check out these two functions and the .INI file structure.
_________________________
There are two types of vessels, submarines and targets.

Top
#76850 - 2003-09-23 11:21 PM Re: Ready ?
KiXrookie Offline
Fresh Scripter

Registered: 2003-09-19
Posts: 19
Thanks for the advice, I'm in the process of testing the Read/Write ProfileString commands but in the meantime do you know why there is a 1 being appended to the previous line in my text file after another line is added?

[ipadds.txt]

165. 48. 73.169 4.90 B0000F6DD601B1
165. 48. 97.101 4.83 B0040811FB1E41
165. 48. 44.109 4.83 B0000412FE233

Top
#76851 - 2003-09-23 11:45 PM Re: Ready ?
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Yes I do! Unhandled return codes. It is all explained in the FAQ!
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#76852 - 2003-09-24 11:16 PM Re: Ready ?
KiXrookie Offline
Fresh Scripter

Registered: 2003-09-19
Posts: 19
Yep, Yep!! Got it resolved. I'll get there at some point.
Top
Page 1 of 1 1


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Mart 
Hop to:
Shout Box

Who's Online
2 registered (b15145, mole) and 194 anonymous users online.
Newest Members
Stefan_H, khalidkhan786, BigDGeorge, jefff, QCarvalho
17672 Registered Users

Generated in 0.035 seconds in which 0.012 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