User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Shell Scripting section within the Software Development category of DaniWeb, a massive community of 430,118 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,318 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Shell Scripting advertiser: Programming Forums
Views: 5672 | Replies: 5
Reply
Join Date: Nov 2004
Posts: 3
Reputation: giany is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
giany giany is offline Offline
Newbie Poster

Arping script

  #1  
Nov 28th, 2004
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 :

#!/bin/bash
i=1
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`
done
echo " Done "
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Dec 2003
Location: Nashville, TN
Posts: 2,333
Reputation: alc6379 has a spectacular aura about alc6379 has a spectacular aura about alc6379 has a spectacular aura about 
Rep Power: 11
Solved Threads: 102
Colleague
alc6379's Avatar
alc6379 alc6379 is offline Offline
Cookie... That's it

Re: Arping script

  #2  
Dec 6th, 2004
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?
Alex Cavnar, aka alc6379
Reply With Quote  
Join Date: Nov 2004
Posts: 21
Reputation: vgersh99 is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
vgersh99's Avatar
vgersh99 vgersh99 is offline Offline
Newbie Poster

Re: Arping script

  #3  
Dec 6th, 2004
#!/bin/ksh

typeset iter=0

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

while :
do
   ls /tmp > /dev/null
   iter=$(( iter + 1))
done
vlad
+-----------------------------------+
| #include <disclaimer.h> |
+-----------------------------------+
Reply With Quote  
Join Date: Nov 2004
Posts: 3
Reputation: giany is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
giany giany is offline Offline
Newbie Poster

Re: Arping script

  #4  
Jan 7th, 2005
Bash.. still has its faults..
#! /bin/csh -f

set client = (10.0.0.2 10.0.0.3)

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

Now when i press Ctrl+C it stops..
I guess i`ll try perl
Reply With Quote  
Join Date: Nov 2004
Posts: 3
Reputation: giany is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
giany giany is offline Offline
Newbie Poster

Re: Arping script

  #5  
Jan 7th, 2005
vgersh99 : how will that help me?
Reply With Quote  
Join Date: Nov 2004
Posts: 21
Reputation: vgersh99 is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
vgersh99's Avatar
vgersh99 vgersh99 is offline Offline
Newbie Poster

Re: Arping script

  #6  
Jan 7th, 2005
this is a hint/template how to use 'trap' with the interrupt [eg ^C].
vlad
+-----------------------------------+
| #include <disclaimer.h> |
+-----------------------------------+
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Shell Scripting Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the Shell Scripting Forum

All times are GMT -4. The time now is 3:19 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC