Re: readLine method help
- From: Kendoh <Kendoh@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 22 Apr 2005 14:13:03 -0700
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
>
.
- Follow-Ups:
- Re: readLine method help
- From: Torgeir Bakken \(MVP\)
- Re: readLine method help
- References:
- readLine method help
- From: Kendoh
- Re: readLine method help
- From: Torgeir Bakken \(MVP\)
- readLine method help
- Prev by Date: Re: readLine method help
- Next by Date: Re: Number problem
- Previous by thread: Re: readLine method help
- Next by thread: Re: readLine method help
- Index(es):
Relevant Pages
|
Loading