Hello i`m trying to make a script that shows me online users using the arping command.
I want to enable to stop it using Ctrl +C and print me a message : Continue Y/N. And one more thing in the end to print me : We have $wc -l users online. Smth like that.
Can anyone help?

Here is what i did so far :

while [ $i -lt 190 ] ; do
arping -I eth1 -c 1 10.0.0.$i | grep Unicast
#arp -an | grep "(10.0.0.$i)"
i=`echo $i + 1 | bc`
echo " Done "

Recommended Answers

All 5 Replies

Are you sure you'll be able to use Ctrl-C with the shell? I'd be afraid that the script will just stop being interpreted by the shell, and just dump to a prompt. Perhaps you should be looking at some scripting language (Python or Perl, for instance) where you can simply raise an exception whenever Ctrl-C is pressed?


typeset iter=0

trap 'echo "$(date): iter->[${iter}]";exit' INT;

while :
   ls /tmp > /dev/null
   iter=$(( iter + 1))
commented: AWESOME signature! :D +5

Bash.. still has its faults..
#! /bin/csh -f

set client = (

foreach client ($client)
set status = `arping -I eth1 -c 1 $client | grep "Received 0 response"`
if ($#status > 0) then
#echo "$client is dead"
echo "$client is online"

Now when i press Ctrl+C it stops..
I guess i`ll try perl

vgersh99 : how will that help me?

this is a hint/template how to use 'trap' with the interrupt [eg ^C].

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.