Reputation: 131
I have To implement ping command response, with TCL on a Linux platorm. I need to get a true or false flag in TCL depending on whether server is connected or not. Based on that I need to do some manipulation.
Any one help?
Upvotes: 2
Views: 1219
Reputation: 117
Using exec probably is enough for unix systems, but you might want to use a more direct approach, eg. for use on multi-platform scripts
Digging around, the nsicmp TCL package seems to provide such ICMP ping support : https://bitbucket.org/naviserver/nsicmp/overview
Upvotes: 1
Reputation: 55483
Just exec
the regular ping
binary and catch its error code: Unix ping returns 0, 1 or 2 depending on whether it suceeded in verifying the host's reachability of not.
You'll probablty need to use -n N
and -q
options to ping
and redirect its stdout and stderr to /dev/null
.
For an example on how to call an external program via exec
and trap possible errors see the "Unix" section down in the exec
manual page.
See also this wiki page.
Upvotes: 3