Re: asp script to ping four IP address from text file
From: David Wang [Msft] (someone_at_online.microsoft.com)
Date: 02/22/04
- Next message: LMY: "Custom Attributes"
- Previous message: Viatcheslav V. Vassiliev: "Re: Tabular Data Control Help"
- In reply to: weiwei: "asp script to ping four IP address from text file"
- Messages sorted by: [ date ] [ thread ]
Date: Sun, 22 Feb 2004 01:29:29 -0800
You've got a logical bug in your code.
1. The script first opens a file and reads each line into an array.
2. Then, it calls a batch file on each array element, which presumably
writes something to another file
3. Finally, it reads another file and writes it out character-by-character
to HTML.
If you want all PING command output to be displayed in HTML, either you need
to make sure each call of the batch file concatentates output, or you need
to make #3 happen for each invocation of the batch file.
--
//David
IIS
This posting is provided "AS IS" with no warranties, and confers no rights.
//
"weiwei" <Wei.Huang@slps.org> wrote in message
news:d32b0478.0402191257.2ba40114@posting.google.com...
Hi
I am trying to write a asp script to ping four IP address from text
file. I want to list of IP addresses are down and display them in HTML
pages. so far, my script can read each ip address and ping them,
however, on html page, it only show up one IP address which was not
down. that is abou it. in addition, It also created four notepad
showing their status either they were down or not. anyone can help me
out
Below is my code
<%
Dim arrFileLine()
I = 0
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("C:\ping.txt", 1)
Do Until objFile.AtendOfStream
ReDim Preserve arrFileLines(I)
arrFileLines(I) = objFile.ReadLine
I = I + 1
Loop
objFile.close
For l = UBound(arrFileLines) To LBound(arrFileLines) Step -1
IP = arrFileLines(l)
Set FileSys = Server.CreateObject("Scripting.FileSystemObject")
FileName = FileSys.GetTempName
Set WShShell = Server.CreateObject("WScript.Shell")
RetCode = WShShell.Run("c:\Inetpub\wwwroot\cgi-bin\DoPing.bat " & IP &
" " & FileName, 1, True)
if RetCode = 0 Then
else
end if
Next
Set TextFile = FileSys.OpenTextFile("c:\InetPub\wwwroot\cgi-bin\" &
FileName & ".txt", 1)
TextBuffer = TextFile.ReadAll
For i = 1 to Len(TextBuffer)
If Mid(TextBuffer,i,1) = chr(13) Then
Response.Write("<BR>")
else
Response.Write(Mid(TextBuffer,i,1))
end if
Next
TextFile.Close
%>
- Next message: LMY: "Custom Attributes"
- Previous message: Viatcheslav V. Vassiliev: "Re: Tabular Data Control Help"
- In reply to: weiwei: "asp script to ping four IP address from text file"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|