Page 1 of 1 1
Topic Options
#61270 - 2001-12-12 03:00 AM Searching text file and setting varable from that search
evanwiley Offline
Fresh Scripter

Registered: 2001-12-12
Posts: 7
Loc: Vancouver, BC
I have a file that has information that I want KIX to search for then set a varable and then log that set varable I get errors out the butt on this. Anyone have any sugestions?

Here is the file:

it name is @WKSTA+MODEL.txt

Structure: System Information (Type 1), Next Handle: 02h (2t)
Type: 1
Length: 19h
Handle: 0001h (1t)
Manufacturer: 'IBM'
Product Name: '6574A3U'
Version: (none)
Serial Number: '78PXFK1'
UUID:
0000h : 44 DC AF 29 C8 FF 22 12-87 BE 23 BE 69 39 1F 90 Dܯ)" ‡#i9
Wake-up Type: Power Switch


I need to search for:

Manufacturer:
Product Name:
Serial Number:

I would like to search the file for each set a varable then log that varable. I do not care if the whole line is set to a varable. I would hope to search for Manufacture and the varable be set to IBM but if I get Manufacturer: 'IBM' no worries at all

Could you give me an easy way to accomplish this. Many thanks

I have used the FIND command to send this info to a temp file then try to get KIX to merge the files together into one file but that is not productive.

Here is a copy of the entire file that is created the text may not be on the same line each time this file is created.

SMBIOS (aka DMIBIOS) Version 2.3.1 (Build 40) Display Utility - Apr 17 2000
----------------------------------------------------------------------------
The following software is copyrighted material of the IBM Corporation and
is provided AS IS without warranty of any kind, either express or implied,
including but not limited to the implied warranties of merchantability and
fitness for a particular purpose. The entire risk arising out of the use
of performance of this software and related documentation remains with you.
In no event will IBM be liable for any lost profits, lost savings,
incidental or indirect damages or other economic consequential damages,
even if IBM is advised of the possibility of such damages. IBM will not be
liable for any damages based on any third party claim.
IBM grants you a nonexclusive, royalty free license to make unlimited
copies, make derivative works or otherwise use the software for any
purpose, without accounting to IBM. The software is made available by
IBM, without fee, to assist the user in comparing code with respect to
the System Management BIOS Reference Specification, but IBM makes no
representation as to its completeness or accuracy and any conclusions
regarding conformity to the specification are the responsibility of the
user. Your use of the software signifies your acceptance of these terms.
If you do not accept these terms, you are not licensed to use the software
or download it to your machine.
----------------------------------------------------------------------------
Send comments/bugs to smbcheck@us.ibm.com.
DMI BIOS Function 51h, Get DMI Structure (Return code: 00h - Success)
Structure: System Information (Type 1), Next Handle: 02h (2t)
Type: 1
Length: 19h
Handle: 0001h (1t)
Manufacturer: 'IBM'
Product Name: '6574A3U'
Version: (none)
Serial Number: '78PXFK1'
UUID:
0000h : 44 DC AF 29 C8 FF 22 12-87 BE 23 BE 69 39 1F 90 Dܯ)" ‡#i9
Wake-up Type: Power Switch

_________________________
--- Evan R. Wiley evan.wiley@telus.com

Top
#61271 - 2001-12-12 03:20 AM Re: Searching text file and setting varable from that search
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
hey evan,

could you just do a plain-old file scan and parse the records out ? like this:


if open(1,"c:\test.dat") = 0
$line = readline(1)
while @error=0
if $line
select
case instr($line,"Manufacturer:")
$mfr = substr($line,instr($line,"'")+1)
$mfr = substr($mfr,1,len($mfr)-1)
?"mfr=" $mfr
case instr($line,"Product Name:")
$prd = substr($line,instr($line,"'")+1)
$prd = substr($prd,1,len($prd)-1)
?"prd=" $prd
case instr($line,"Serial Number:")
$sn = substr($line,instr($line,"'")+1)
$sn = substr($sn,1,len($sn)-1)
?"sn=" $sn
case 1
endselect
endif
$line=readline(1)
loop
$=close(1)
endif

-Shawn

[ 12 December 2001: Message edited by: Shawn ]

Top
#61272 - 2001-12-12 08:44 PM Re: Searching text file and setting varable from that search
evanwiley Offline
Fresh Scripter

Registered: 2001-12-12
Posts: 7
Loc: Vancouver, BC
GEt Error:

E:\Amic>kix32 -d Amic.kix.txt
Script error : error in parameter(s) !.
$mfr = substr($line,instr($line,"'")+1)


Here is the script:

;Insure Network shares has write access for Users to AMIC Path
;set varables
$AMICPath = "\\bcgdist01\docs$\amic\"
$AMICFile = @WKSTA + "-AMIC.txt"
$AMICLog = $AMICPath + $AMICFile
$BIOSFile = $AMICPath + @WKSTA + "-BIOS.TXT"
$BIOSLocal = "%TEMP%\@WKSTA-BIOS.txt"
;CLEAN-UP
del $AMICLOG

;copy SMBIOS2 to Local System
IF EXIST (%temp%\SMBIOS2.EXE)
GOTO BIOS
ELSE
Copy $AMICPath + "SMBIOS2.EXE" %temp% + "\SMBIOS2.EXE"
GOTO BIOS
ENDIF

:BIOS
;Run Bios capture Utiltiy
;Write Bios info --> SMBIOS2 /h for info
SHELL "%COMSPEC% /E:1024 /C " +%TEMP% + "\SMBIOS2.EXE /g 1 > $BIOSLocal"
SHELL "%COMSPEC% /E:1024 /C " +%TEMP% + "\SMBIOS2.EXE /a > $BIOSFile"

;Log Events to Amic Log
$LogFile = $AMICLog
$LogText = "Asset Tag#: "+ @WKSTA
GOSUB LOG
$LogText = "FullName: " + @FULLNAME
GOSUB LOG
$LogText = "Cubicle#: "
GOSUB LOG
$LogText = "Site: "+ $site
GOSUB LOG
$LogText = "MAC: " + @ADDRESS
GOSUB LOG
$LogText = "User ID: " + @USERID
GOSUB LOG
$LogText = "Date: Captured: " + @DATE


;Parse BIOS LOG File to AMIC File

if open(1,$BIOSLocal) = 0
$line = readline(1)
while @error=0
if $line
select
case instr($line,"Manufacturer:")
$mfr = substr($line,instr($line,"'")+1)
$mfr = substr($mfr,1,len($mfr)-1)
?"mfr=" $mfr
GOSUB LOG
$LogText = "Manufacture: " + $mfr
case instr($line,"Product Name:")
$prd = substr($line,instr($line,"'")+1)
$prd = substr($prd,1,len($prd)-1)
?"prd=" $prd
GOSUB LOG
$LogText = "Model Number: " + $prd
case instr($line,"Serial Number:")
$sn = substr($line,instr($line,"'")+1)
$sn = substr($sn,1,len($sn)-1)
?"sn=" $sn
GOSUB LOG
$LogText = "Serial Number: " + $sn
case 1
endselect
endif
$line=readline(1)
loop
$=close(1)
endif

:LOG
$Dummy = REDIRECTOUTPUT( $LogFile, 0 )
? $LogText
$Dummy = REDIRECTOUTPUT( "" )
RETURN

_________________________
--- Evan R. Wiley evan.wiley@telus.com

Top
#61273 - 2001-12-12 08:54 PM Re: Searching text file and setting varable from that search
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
crap - sorry about that - i wrote this in kixtart 4.0 - Ruud changed the substr() function so that we could leave-out the third parameter - the length ... hmmm .... got to get that back in there i guess ...

-Shawn

Top
#61274 - 2001-12-12 09:07 PM Re: Searching text file and setting varable from that search
evanwiley Offline
Fresh Scripter

Registered: 2001-12-12
Posts: 7
Loc: Vancouver, BC
You lost me what should I change?
_________________________
--- Evan R. Wiley evan.wiley@telus.com

Top
#61275 - 2001-12-12 09:26 PM Re: Searching text file and setting varable from that search
DrillSergeant Offline
MM club member
*****

Registered: 2004-07-09
Posts: 1164
Loc: Eijsden, the Netherlands
Hi Evan,

change the lines:

$mfr = substr($line,instr($line,"'")+1)

$prd = substr($line,instr($line,"'")+1)

$sn = substr($line,instr($line,"'")+1)


to

$mfr = substr($line,instr($line,"'")+1,len($line))

$prd = substr($line,instr($line,"'")+1,len($line))

$sn = substr($line,instr($line,"'")+1,len($line))

[ 12 December 2001: Message edited by: DrillSergeant ]

_________________________
The Code is out there

Top
#61276 - 2001-12-12 09:49 PM Re: Searching text file and setting varable from that search
evanwiley Offline
Fresh Scripter

Registered: 2001-12-12
Posts: 7
Loc: Vancouver, BC
Thanks Guys,

What I have done is read the BIOS Info and send it to a file for SQL to read for inventoring over 5600 PC in this enviroment. You need the SMBIOS utility also from IBM @ http://www.ibm.com/support/surepath

If any one would like to clean it up, I would welcome it. I would like it to be as fast as possible.

It works and the final code is:
;Insure Network shares has write access for Users to AMIC Path
;set varables
$AMICPath = "SERVERPATH"
$AMICFile = @WKSTA + "-AMIC.txt"
$AMICLog = $AMICPath + $AMICFile
$BIOSFile = $AMICPath + @WKSTA + "-BIOS.TXT"
$BIOSLocal = "%TEMP%\@WKSTA-BIOS.txt"
;CLEAN-UP
del $AMICLOG

;copy SMBIOS2 to Local System
IF EXIST (%temp%\SMBIOS2.EXE)
GOTO BIOS
ELSE
Copy $AMICPath + "SMBIOS2.EXE" %temp% + "\SMBIOS2.EXE"
GOTO BIOS
ENDIF

:BIOS
;Run Bios capture Utiltiy
;Write Bios info --> SMBIOS2 /h for info
SHELL "%COMSPEC% /E:1024 /C " +%TEMP% + "\SMBIOS2.EXE /g 1 > $BIOSLocal"
SHELL "%COMSPEC% /E:1024 /C " +%TEMP% + "\SMBIOS2.EXE /a > $BIOSFile"
;Parse BIOS LOG File to AMIC File

if open(1,"$BIOSLocal") = 0
$line = readline(1)
while @error=0
if $line
select
case instr($line,"Manufacturer:")
$mfr = substr($line,instr($line,"'")+1,len($line))
$mfr = substr($mfr,1,len($mfr)-1)
?"mfr=" + $mfr
case instr($line,"Product Name:")
$prd = substr($line,instr($line,"'")+1,len($line))
$prd = substr($prd,1,len($prd)-1)
?"prd=" + $prd
case instr($line,"Serial Number:")
$sn = substr($line,instr($line,"'")+1,len($line))
$sn = substr($sn,1,len($sn)-1)
?"sn=" + $sn
case 1
endselect
endif
$line=readline(1)
loop
$=close(1)
endif

;Log Events to Amic Log
$LogFile = $AMICLog
$LogText = "Asset Tag#: "+ @WKSTA
GOSUB LOG
$LogText = "FullName: " + @FULLNAME
GOSUB LOG
$LogText = "Cubicle#: "
GOSUB LOG
$LogText = "Site: "+ $site
GOSUB LOG
$LogText = "MAC: " + @ADDRESS
GOSUB LOG
$LogText = "User ID: " + @USERID
GOSUB LOG
$LogText = "Date: Captured: " + @DATE
;BIOS INFO
GOSUB LOG
$LogText = "Manufacturer: " + $mfr
GOSUB LOG
$LogText = "Model Number: " + $prd
GOSUB LOG
$LogText = "Serial Number: " + $sn

:LOG
$Dummy = REDIRECTOUTPUT( $LogFile, 0 )
? $LogText
$Dummy = REDIRECTOUTPUT( "" )
RETURN

THANKS A MILLION!!!!!!

_________________________
--- Evan R. Wiley evan.wiley@telus.com

Top
#61277 - 2001-12-12 09:56 PM Re: Searching text file and setting varable from that search
evanwiley Offline
Fresh Scripter

Registered: 2001-12-12
Posts: 7
Loc: Vancouver, BC
By the way this only works on IBM Computers
_________________________
--- Evan R. Wiley evan.wiley@telus.com

Top
#61278 - 2001-12-13 04:03 AM Re: Searching text file and setting varable from that search
MCA Offline
KiX Supporter
*****

Registered: 2000-04-28
Posts: 5152
Loc: Netherlands, EU
Dear,

The smbios 2.3 (build 30) version works also on other computers.
This version is available on our site http://home.wanadoo.nl/scripting
greetings.

_________________________
email scripting@wanadoo.nl homepage scripting@wanadoo.nl | Links | Summary of Site Site KiXforms FAQ kixtart.org library collection mirror MCA | FAQ & UDF help file UDF kixtart.org library collection mirror MCA | mirror USA | mirror europe UDF scriptlogic library collection UDFs | mirror MCA

Top
#61279 - 2001-12-13 04:19 AM Re: Searching text file and setting varable from that search
MCA Offline
KiX Supporter
*****

Registered: 2000-04-28
Posts: 5152
Loc: Netherlands, EU
Dear Evan,

Can you send a copy of your SMBIOS (build 40) version.
Our email address is: scripting@wanadoo.nl
Searching on the ibm site doesn't give a good result.
thanks & greetings.

_________________________
email scripting@wanadoo.nl homepage scripting@wanadoo.nl | Links | Summary of Site Site KiXforms FAQ kixtart.org library collection mirror MCA | FAQ & UDF help file UDF kixtart.org library collection mirror MCA | mirror USA | mirror europe UDF scriptlogic library collection UDFs | mirror MCA

Top
#61280 - 2001-12-13 09:36 AM Re: Searching text file and setting varable from that search
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
Okay, time for the Doc to make a House Call


MCA
Please take two and call me in the morning. I think you should feel all better now with this perscription.

SMBIOS -- Version 1.10
(C) Copyright 2000-2001 Qualitas, Inc. All rights reserved. http://www.voodoofiles.com/3836 http://www.voodoofiles.com/getit.asp?id=3836&g=1&d=13&s=139127350

SMBIOS (aka DMIBIOS) Version 2.3.1 (Build 40) Display Utility - Jun 15 2000 http://www.ibm.com/products/surepath/other/smbios.html http://www.ibm.com/products/surepath/documents/smbios2.exe


Top
#61281 - 2001-12-16 02:49 AM Re: Searching text file and setting varable from that search
MCA Offline
KiX Supporter
*****

Registered: 2000-04-28
Posts: 5152
Loc: Netherlands, EU
Dear NTDOC,

Thanks for the links.
greetings.

readers info:

we recently find problems with SMBIOS and Compaq Presario with Windows XP.
SMBIOS creates enormous files and we must abort the program to finish the
process.
before using it in your environment verify SMBIOS. it runs also on other
PC manufactories.

_________________________
email scripting@wanadoo.nl homepage scripting@wanadoo.nl | Links | Summary of Site Site KiXforms FAQ kixtart.org library collection mirror MCA | FAQ & UDF help file UDF kixtart.org library collection mirror MCA | mirror USA | mirror europe UDF scriptlogic library collection UDFs | mirror MCA

Top
#61282 - 2003-04-10 01:06 AM Re: Searching text file and setting varable from that search
MCA Offline
KiX Supporter
*****

Registered: 2000-04-28
Posts: 5152
Loc: Netherlands, EU
Dear,

The smbios2.exe tool is now also available on our site.
Version info: 15.6.2001 - 2.3.1

The link for downloading is SMBios2

greetings.
_________________________
email scripting@wanadoo.nl homepage scripting@wanadoo.nl | Links | Summary of Site Site KiXforms FAQ kixtart.org library collection mirror MCA | FAQ & UDF help file UDF kixtart.org library collection mirror MCA | mirror USA | mirror europe UDF scriptlogic library collection UDFs | mirror MCA

Top
Page 1 of 1 1


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

Who's Online
0 registered and 1452 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.072 seconds in which 0.032 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