vbscript - Strange Variable assignments
-
Wednesday, January 30, 2013 4:58 PM
Not sure where its happening but I'm getting some really strange output from variables when trying to combine.
Here is the code
vAdpDesc = Adapters.DescriptionvAdpMac = Adapters.MACAddressstrDebugMSG = strDebugMSG & "Adapter Description:" & vAdpDesc & " Adapter MAC:" & vAdpMac & vbCrLfvTempOut = vSysDrive & "\temp\adapter_" & replace(vAdpMac,":","") & "_out.txt"vCMD = "cmd /c " & """" & vSysDrive & "\Program Files\Broadcom\BACS\BACScli.exe"" -t NDIS -f mac -i " & replace(vAdpMac,":","") & " info > " & vTempOut strDebugMSG = strDebugMSG & "CMD:" & vCMD & vbCrLfWshShell.Run vCMD,0,TruevDuplex = "N/A"vSpeed = "N/A"If objFSO.FileExists (vTempOut) ThenSet objNIC=objFSO.OpenTextFile (vTempOut,1)Do Until objNIC.AtEndOfStreamvLine = Trim(objNIC.Readline)arLine = split(vLine,":")If Instr(vLine,"Duplex") > 0 ThenvDuplex = Trim(arLine(2))strDebugMSG = strDebugMSG & "Duplex Line:" & vLine & vbCrLfstrDebugMSG = strDebugMSG & "Duplex:" & vDuplex & vbCrLfEnd IfIf Instr(vLine,"Speed") > 0 ThenvSpeed = Trim(arLine(2))strDebugMSG = strDebugMSG & "Speed Line:" & vLine & vbCrLfstrDebugMSG = strDebugMSG & "Speed:" & vSpeed & vbCrLfEnd IfLoopEnd Ifwscript.echo vAdpMac & "," & vSpeedwscript.echo vAdpMac & "," & vDuplexwscript.echo vAdpMac & "," & vSpeed & "," & vDuplex
Here is the output I am seeing
00:1E:4F:3A:36:D8,100000:1E:4F:3A:36:D8,Full,Full :36:D8,1000
00:1E:4F:3A:36:D6,100000:1E:4F:3A:36:D6,Full,Full :36:D6,1000
00:1E:4F:3A:36:D8,100000:1E:4F:3A:36:D8,Full,Full :36:D8,1000As you can see on the first 2 echos I'm seeing exactly what I would expect from all the variables but when we get to the last echo it goes all strange and honestly I don't know why since its the next line in the code after seeing they were all ok. You can see the speed and duplex swap and then the mac is being added to the speed and cutting it off and not showing anything in the mac location at all.
Thanks in advance
--Todd
All Replies
-
Wednesday, January 30, 2013 8:11 PMModerator
That's usually the result of a line of text that contains a carriage return without a linefeed. It would therefore appear to be because of the BACScli.
exe procedure. It might be possible to fix it with a pipe through the FIND utility ... ...\BACScli.
exe ... & "info | find /v """" > " ... If that doesn't fix it, you will need to Replace(string, vbCR, vbCRLF) and then parse the line again at the newline.
Tom Lavedas
- Marked As Answer by twooly Thursday, January 31, 2013 11:21 AM
-
Thursday, January 31, 2013 11:21 AM
That was it, did a replace on vbCR on the new line read.
Thank you very much.

