Re: readLine method help



Now I have this problem... I am trying to get all computers of a subnet into
a txt file. Here is the code. I am not getting any output... When I use your
code without the if loop, it writes localhost into the document... What am I
doing wrong?

dim fso, fl, count
count = 1
ip = 1
Set fso = CreateObject("Scripting.FileSystemObject")
Set fl = fso.CreateTextFile("C:\\Temp\Test.txt", true)

if count <> 256 Then
Set objShell = CreateObject("WScript.Shell")
Set objWshScriptExec = objShell.Exec("nslookup 158.187.145.&count&")
Set objStdOut = objWshScriptExec.StdOut

Do Until objStdOut.AtEndOfStream
strLine = objStdOut.ReadLine
If Left(strLine, 5) = "Name:" Then
strName = Mid(strLine, 10)
Exit Do
End If
Loop
fl.WriteLine(strName)
count = count + 1

end if


"Torgeir Bakken (MVP)" wrote:

> Kendoh wrote:
>
> > I am using a basic script to learn how to readLine certain portions of the
> > nslookup cmd output. When you nslookup something you get "Name:
> > localhost" for example. How do I chop off the "Name: " so that when i
> > assign the output to a string, i only have "localhost" stored?? Here is the
> > code I am using...
> >
> > Set objShell = CreateObject("WScript.Shell")
> > Set objWshScriptExec = objShell.Exec("nslookup 127.0.0.1")
> > Set objStdOut = objWshScriptExec.StdOut
> >
> > While Not objStdOut.AtEndOfStream
> > strLine = objStdOut.ReadLine
> > If InStr(strLine,"Name") Then
> > wscript.echo strLine
> > End If
> >
> > Wend
> Hi
>
> '--------------------8<----------------------
>
> Set objShell = CreateObject("WScript.Shell")
> Set objWshScriptExec = objShell.Exec("nslookup 127.0.0.1")
> Set objStdOut = objWshScriptExec.StdOut
>
> Do Until objStdOut.AtEndOfStream
> strLine = objStdOut.ReadLine
> If Left(strLine, 5) = "Name:" Then
> strName = Mid(strLine, 10)
> Exit Do
> End If
> Loop
>
> WScript.Echo strName
>
> '--------------------8<----------------------
>
>
> --
> torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
> Administration scripting examples and an ONLINE version of
> the 1328 page Scripting Guide:
> http://www.microsoft.com/technet/scriptcenter/default.mspx
>
.



Relevant Pages

  • Re: readLine method help
    ... >> strLine = objStdOut.ReadLine ... > WScript.Echo strName ... > torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway ...
    (microsoft.public.scripting.vbscript)
  • Re: Net Send script help
    ... How can I modify my script to display a list of all the PCs that got the message using the msgbox function? ... For Each strName in arrPCNames ... strNameSum = strNameSum & vbCrLf & strName ... torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway Administration scripting examples and an ONLINE version of the 1328 page Scripting Guide: ...
    (microsoft.public.scripting.vbscript)
  • Re: Active Directory: Find Disable Users Email address
    ... First off let me say my knowledge of scripting is limited however I'm ... I have found a script that lists disabled users' Distinguished Name and I ... strDN = objRecordSet.Fields.Value ... strLine = strDN ...
    (microsoft.public.scripting.vbscript)
  • Re: reset passwords
    ... ' the user belongs to in the variable "strNetBIOSDomain". ... On Error GoTo 0 ... objUser.SetPassword strName ... -- torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway Administration scripting examples and an ONLINE version of the 1328 page Scripting Guide: ...
    (microsoft.public.windows.server.scripting)
  • Re: readLine method help
    ... Is there a way to make the cmd execution window not ... >> code without the if loop, it writes localhost into the document... ... > Set objStdOut = objWshScriptExec.StdOut ... > torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway ...
    (microsoft.public.scripting.vbscript)

Loading