Page 1 of 1 1
Topic Options
#123193 - 2004-07-18 12:23 PM howto read furter in readline if value is not same
expodium Offline
Fresh Scripter

Registered: 2004-07-14
Posts: 35
hi,

i try to get the ip mask from my NIC but what if i have 2 NIC's? i get in my temp file 2 lines with subnet mask but if the first one is not that what i need, how can i go further to the second line?

this script is needed on aboud 500 computers so, i cant use it by nic name or by registry search because differents Nic's.

Her is my code to read the first line of the temp txt file:

Function IPConfig($IPType)
If NOT $IPLine
Shell '%comspec% /c ipconfig | find "$IPType" >$file'
If Open (1, $file, 2) = 0
$line = ReadLine(1)
If InStr($line, $IPType)
$IPLine = Trim(Split($line,':')[1])
EndIf
EndIf
EndIf
$X = Close(1)
Del $file
EndFunction

and the example of the output:

Subnet Mask . . . . . . . . . . . : 255.255.255.0
Subnet Mask . . . . . . . . . . . : 255.255.240.0

this is at the moment in a test environment and normally needed for reading IP and if IP is same as IP from local DHCP server (not DHCP from ISP), get subnetmask from file

thanks in advance

Expodium


Edited by expodium (2004-07-18 12:31 PM)

Top
#123194 - 2004-07-18 02:39 PM Re: howto read furter in readline if value is not same
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
If you are piping this out to a text file, you could use the TAIL() UDF from the UDF Forum to have it go to the very bottom of the file you are reading in..

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#123195 - 2004-07-18 05:52 PM Re: howto read furter in readline if value is not same
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
You could rewrite your UDF to read in multiple lines by putting ReadLine() inside a DO - UNTIL loop and then return the result as an array. Then in your line calling the UDF just check the VarType()/UBound() of the returned result.

You might want to consider writing a UDF that gets all the properties in a single call instead of calling it multiple times and passing parms. Also, your UDF has dependencies on vars not local to the UDF which is not a best practice.

You may want to have a peek at the UDF CheckNICs() - Checks/Updates a NICs TCP/IP settings for ideas on how to do it without SHELLing out to DOS.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#123196 - 2004-07-18 06:01 PM Re: howto read furter in readline if value is not same
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
It might be even easier to just enumerate all present NICs via WMI and then retrieve the associated IP addresses and subnet masks for each NIC.
_________________________
There are two types of vessels, submarines and targets.

Top
#123197 - 2004-07-18 06:08 PM Re: howto read furter in readline if value is not same
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
..assuming the clients are WMI capable.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

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 874 anonymous users online.
Newest Members
StuTheCoder, M_Moore, BeeEm, min_seow, Audio
17884 Registered Users

Generated in 0.311 seconds in which 0.243 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