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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ColdFusion Ping 2

Status
Not open for further replies.

Signit

MIS
Oct 17, 2003
114
US
I need to do a ping from ColdFusion. I am running ColdFusion MX 6.1. Is there a way to do this? Any help would be greatly appreciated.
 
Here is a little script I use internally after our occassional crappy power failures.. It is obviously somewhat tailored to my environment, such as the IP address range, and the fact that ping.exe is located in c:\winnt\system32 directory (windows 2000), and all I'm looking for is success or failure.. you could parse other info out of the file or use hostnames instead of ip addresses.. enjoy

Code:
<cfset dir=getdirectoryfrompath(getcurrenttemplatepath())>

<table>
<cfloop from="254" to="200" index="lp" step="-1">
	<cfset ip="10.1.1.#lp#">
	<cfset filename="10.1.1.#numberformat(lp,"000")#.txt">
	<cfexecute name="c:\winnt\system32\ping.exe" arguments="#ip# -n 1" timeout="5" outputfile="#dir##filename#"></cfexecute>
	<cffile action="READ" file="#dir##filename#" variable="txt">
	<tr>
		<td><cfoutput>#ip#</cfoutput></td>
		<td>
			<cfif txt contains "Reply from #ip#">
				SUCCESS
			<cfelseif txt contains "Request timed out.">
				-failed-
			<cfelse>
				<font color="Red">unknown</font>
			</cfif>
		</td>
	</tr>
</cfloop>
</table>
 
I haven't tested it, but good post.

We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true.
 
That is a pretty slick way of doing things. I am working on a solaris server so the syntax will be slightly different, but thanks for the help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top