Re: asp script to ping four IP address from text file

Tech-Archive recommends: Speed Up your PC by fixing your registry

From: David Wang [Msft] (someone_at_online.microsoft.com)
Date: 02/22/04


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
%>


Relevant Pages

  • Re: Form Data -> Variables or an Array?
    ... Forgive me I am a PHP newbie. ... I have a small script that enables me to ... I want to use the HTML formatted form ... variables or an array, so that I can call the data later in the same ...
    (comp.lang.php)
  • Re: Need to be able to add print option or save as option to the outpout of this script....
    ... First get all the names and shove them in an array. ... building script, then, start building the page, when you get to the section ... Then write the end bit of code into a string. ... If I'm right then this will display the html in a browser. ...
    (microsoft.public.scripting.vbscript)
  • Re: Form Data -> Variables or an Array?
    ... Forgive me I am a PHP newbie. ... I have a small script that enables me to ... I want to use the HTML formatted form because ... variables or an array, so that I can call the data later in the same ...
    (comp.lang.php)
  • Re: Form Data -> Variables or an Array?
    ... Forgive me I am a PHP newbie. ... I have a small script that enables me to ... I want to use the HTML formatted form because ... variables or an array, so that I can call the data later in the same ...
    (comp.lang.php)
  • Cant make this page work
    ... I can't make this script work properly. ... The script at the bottom of the html page ... Does someone have a perl ... sub output_trace_headers { ...
    (comp.lang.javascript)