⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ping.asp

📁 SQL2000跟课件学习的源代码 分享共同学习
💻 ASP
字号:
<html>
<head><title>在Asp中使用Ping命令</title></head>
<body>
<%
dim  IP, fo, TextFile
IP = Request("IPAddr")	'要ping的地址
if Request("InputPara")="1" then 
  fo="c:\Ping.Bat"
  Set FileSys=Server.CreateObject("Scripting.FileSystemObject")
  Set TextFile=FileSys.createTextFile(fo,TRUE)
  TextFile.Write  "ping -a "& IP &" > c:\PingResult.txt" 
  TextFile.Close
  FileName = FileSys.GetTempName 
  Set WShShell = Server.CreateObject("WScript.Shell") 
  RetCode = WShShell.Run(fo, 1, True) 
  if RetCode <> 0 Then '有错误
    Response.Redirect "PingErrors.htm" 
  else
    Set TextFile = FileSys.OpenTextFile("c:\PingResult.txt", 1) 
    TextBuffer = TextFile.ReadAll 
    For i = 1 to Len(TextBuffer) 
      If Mid(TextBuffer,i,1) = chr(13) Then 
      elseIf Mid(TextBuffer,i,1) = chr(10) Then
        Response.Write("<BR>") 
      else
        Response.Write(Mid(TextBuffer,i,1)) 
      end if 
    Next 
    TextFile.Close 
    FileSys.DeleteFile "c:\PingResult.txt"
    FileSys.DeleteFile fo
  end if 
else   
%>
<p>输入Ping命令的参数</p>
<form action="ping.asp" method="post" name="form1">
  <table width="46%" height="57" border="0" cellpadding="0" cellspacing="0">
    <tr> 
      <td width="26%" height="29"><div align="center">IP地址</div></td>
      <td width="74%"><input name="IPAddr" type="text" id="IPAddr" value="192.168.1.101"> 
        <input name="InputPara" type="hidden" id="InputPara" value="1"></td>
    </tr>
    <tr> 
      <td colspan="2"><div align="center"> 
          <input type="submit" name="Submit" value="Ping">
        </div></td>
    </tr>
  </table>
</form>
<%
  end if  
%>
</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -