•
•
•
•
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
![]() |
•
•
Join Date: Nov 2004
Posts: 3
Reputation:
Rep Power: 0
Solved Threads: 0
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 "
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 "
•
•
Join Date: Dec 2003
Location: Nashville, TN
Posts: 2,333
Reputation:
Rep Power: 11
Solved Threads: 102
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
#!/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> |
+-----------------------------------+
+-----------------------------------+
| #include <disclaimer.h> |
+-----------------------------------+
•
•
Join Date: Nov 2004
Posts: 3
Reputation:
Rep Power: 0
Solved Threads: 0
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
#! /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
![]() |
•
•
•
•
•
•
•
•
DaniWeb Shell Scripting Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- Random Programming Script (Computer Science and Software Design)
- Importing SQL Script File - Urgent !! (Database Design)
- Table of Contents Script (Java)
- ASP slow-down server script (ASP)
Other Threads in the Shell Scripting Forum
- Previous Thread: kwrite and gedit errors
- Next Thread: "shell scripting tutorials?"



Linear Mode