Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Please Help This is what I need to

Status
Not open for further replies.
Jun 7, 2002
4
0
0
US
Please Help
This is what I need to accomplish: there is a text file that contains a list of servers,I need to be able to read the text file (1 line at a time), ping the name, print the results to a file. This is what I have so far.. I can read (the first line) .. ping the name..print it to file.. now what I cannot figure out is how to have it continue to read line by line, ping, and print to file until the end of the file. Please help

Dim Shell
Dim PingExec
Dim PingOutput
Dim Wshshell
Dim SystemPath
Dim Result
Dim Server

SystemPath="C:\winnt\system32"
'set shell = server.createobject("wscript.shell")

Const ForReading = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile _
("c:\arcascripts\test.txt", ForReading, True)
server = objTextFile.ReadLine

Set oShell = CreateObject("WScript.Shell")
Set oFSO = CreateObject("Scripting.FileSystemObject")
oShell.Run "command /C ping.exe " & Server & "> Ping.txt"

Wscript.echo Result
Wscript.Echo server
objTextFile.close


Wscript.Quit
 
titaniumx5,

Don't know if it is the same thing as I have not tested it but you might try something like (eof)


Set objTextFile = objFSO.OpenTextFile
Do while objTextFile.atEndOfStream=false
server=objTextFile.ReadLine
Set oShell = CreateObject("WScript.Shell")
Set oFSO = CreateObject("Scripting.FileSystemObject")
oShell.Run "command /C ping.exe " & Server & "> Ping.txt"

Wscript.echo Result
Wscript.Echo server

Loop

objTextFile.close

good luck,
tsmith
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top