LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 01-21-2014, 04:22 AM   #1
massy
Member
 
Registered: Nov 2013
Distribution: CentOS 6.4
Posts: 209
Blog Entries: 1

Rep: Reputation: Disabled
How to stop fping conditionally


I've used fping to test my wireless modem connection every 10 minites:
fping -ga 192.168.40.0/24 > a.txt

I want to stop it in a shell script, if it could ping even one of them!and doesn't test others.
Is there any way to do it?
 
Old 01-21-2014, 05:32 AM   #2
zhjim
Senior Member
 
Registered: Oct 2004
Distribution: Debian Squeeze x86_64
Posts: 1,748
Blog Entries: 11

Rep: Reputation: 233Reputation: 233Reputation: 233
Quote:
fping -ga 192.168.40.0/24 > a.txt
ret=$?
if [ $ret -eq 0 ]; then
exit 0
fi
I don't really know fping and when it returns. Else got with something like this

Quote:
for i in $(seq 1 254); do
fping -ga 192.168.40.$i >> a.txt
ret=$?
if [ $ret -eq 0 ]; then
exit 0
fi
done
 
1 members found this post helpful.
Old 01-21-2014, 05:56 AM   #3
massy
Member
 
Registered: Nov 2013
Distribution: CentOS 6.4
Posts: 209

Original Poster
Blog Entries: 1

Rep: Reputation: Disabled
Quote:
Originally Posted by zhjim View Post
I don't really know fping and when it returns. Else got with something like this
I did the second part by ping to check:
for i in {1..24}
do
ping -c 1 192.168.40.$i > /home/farid/spt/2
ret=$?
if [ $ret -eq 0 ];then
exit 0
fi
done
when I run it, It doesn't do any thing, and when I press Ctrl+c, It isn't stopped!
 
Old 01-21-2014, 07:05 AM   #4
zhjim
Senior Member
 
Registered: Oct 2004
Distribution: Debian Squeeze x86_64
Posts: 1,748
Blog Entries: 11

Rep: Reputation: 233Reputation: 233Reputation: 233
Also add a timeout to ping -w 5 for 5 seconds timeout. Just it crtl+c many times
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] using fping in a shell for running in crontab massy Linux - General 1 01-21-2014 03:57 AM
fping usage to show only reachble hosts Ole Juul Linux - Networking 1 04-12-2009 12:00 PM
Need help installing FPING Treikayan Linux - Software 2 10-31-2008 10:18 PM
ping from a file (not fping) noir911 Linux - Networking 2 02-04-2008 07:45 PM
fping says > duplicate for [0] saavik Linux - Networking 2 09-30-2002 01:24 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 12:03 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration