hey cfers., I'm trying to ping in cf this way <...
# cfml-beginners
f
hey cfers., I'm trying to ping in cf this way <cfset TargetHost ="204.79.197.200" /> <cfset PingAttempts = 4 /> <cfexecute name="C:\winnt\system32\ping.exe" arguments="#request.TargetHost#" variable="myPing" timeout="8"></cfexecute> <cfif find('Windows',Server.Os.Name)> <cfset Args = "-n #PingAttempts# #TargetHost#" /> <cfelse> <cfset Args = "-c #PingAttempts# #TargetHost#" /> </cfif> <cfexecute name="ping" arguments=#Args# variable="PingResult" timeout=10 /> <cfif PingResult CONTAINS "100% packet loss" OR PingResult CONTAINS "100% loss" > [send alert] </cfif> I'm receiving "key [TARGETHOST] doesn't exist in the request scope" 😫
d
Remove “request.”
TargetHost is set in the local scope.
f
👍😄