This is article presents a simple way to ping a, and get the results of the ping using ASP. The idea is supplied by Bart Silverstein.
A. BAT file needs to is created that is run from the Active Server Page. Let ' s call this file Doping.bat. It'll contain only one statement, which'll ping a passed in IP address. Here's the code for Doping.bat:
Ping-a%1 > D:\INetPub\cgi-bin\%2.txt
This would, if you can's tell, ping the address passed in as the the "the" "the" "Argument" (% 1), and redirect the results To a text file named hy the second command line argument (% 2). Now, let's look how we would the call this from a ASP file:
<%
Set Filesys = Server.CreateObject ("Scripting.FileSystemObject")
FileName = Filesys.gettempname
Set WshShell = Server.CreateObject ("Wscript.Shell")
IP = "204.123.54.1" ' or whatever you want to ping
RetCode = Wshshell.run ("D:\Inetpub\cgi-bin\DoPing.bat" & IP & "" & FileName, 1, True)
%>
Before Hog Wild and implement this code or use similar techniques on your site, there are a few things you should b E wary of. From a secutiry standpoint, the This is really dangerous, for no time you let someone run a application on your server there is always the potential that it'll come back to haunt for you. One suggestion to lessen the Threat:make a separate folder with no script or execute priviledges, and have your doping.ba T output its results to that folder.
I hope this article is informative an interesting. Happy programming!
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.