LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 09-15-2015, 12:48 AM   #1
amartlk
Member
 
Registered: Sep 2010
Location: Nagpur India
Posts: 347

Rep: Reputation: 1
network ping script


Hi

i want to run script which continuos check some ip like 1.2.3.4 when this ip is shows request time out then i have to run another script like abc.bat . and when previous ip 1.2.3.4 is starting pinging then need to run def.bat script
 
Old 09-15-2015, 09:12 AM   #2
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
abc.bat is a Windows batch file.
What is your intended distribution?

ping is unreliable as a 'check'.
Testing Network Services with netcat
Read.
Try.
Ask.
 
Old 09-15-2015, 10:35 AM   #3
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,816

Rep: Reputation: 8003Reputation: 8003Reputation: 8003Reputation: 8003Reputation: 8003Reputation: 8003Reputation: 8003Reputation: 8003Reputation: 8003Reputation: 8003Reputation: 8003
Quote:
Originally Posted by amartlk View Post
Hi

i want to run script which continuos check some ip like 1.2.3.4 when this ip is shows request time out then i have to run another script like abc.bat . and when previous ip 1.2.3.4 is starting pinging then need to run def.bat script
Then you probably should look at the thread you asked this in TWO YEARS AGO, and re-read it:
http://www.linuxquestions.org/questi...pt-4175484297/

Asking for handouts (i.e. "I need a script that does xxxx..."), without showing any effort of your own (again), isn't good.
 
Old 09-16-2015, 07:57 AM   #4
amartlk
Member
 
Registered: Sep 2010
Location: Nagpur India
Posts: 347

Original Poster
Rep: Reputation: 1
thanks for reply
i tried but not resolve issue , actually i have centos squid server in which 2 lan cards are there one connect to switch other to isp .if my isp link is down then i want to connect dongle to one of my pc and internet is provided to all user through my squid server without any changes in client side hence i want to automate this i.e pinging to isp dns is request time out then it set dns and gateway of dongle pc to squid server so that net is started in squid server and then to all clients
 
Old 09-16-2015, 09:40 AM   #5
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,816

Rep: Reputation: 8003Reputation: 8003Reputation: 8003Reputation: 8003Reputation: 8003Reputation: 8003Reputation: 8003Reputation: 8003Reputation: 8003Reputation: 8003Reputation: 8003
Quote:
Originally Posted by amartlk View Post
thanks for reply
i tried but not resolve issue , actually i have centos squid server in which 2 lan cards are there one connect to switch other to isp .if my isp link is down then i want to connect dongle to one of my pc and internet is provided to all user through my squid server without any changes in client side hence i want to automate this i.e pinging to isp dns is request time out then it set dns and gateway of dongle pc to squid server so that net is started in squid server and then to all clients
Great...so AGAIN, you were provided an answer for this two years ago, with sample scripts.

If you want a script, YOU, personally are going to have to write it, or at least show some effort. Re-stating what you need isn't going to get us to write a script for you, especially after two years...have you not done/learned ANYTHING in that time?
 
1 members found this post helpful.
Old 09-23-2015, 02:08 AM   #6
amartlk
Member
 
Registered: Sep 2010
Location: Nagpur India
Posts: 347

Original Poster
Rep: Reputation: 1
i created the below script it work fine
#!/bin/bash
if ping -q -c 1 -w 1 8.8.8.8 >/dev/null; then
echo "ipv4 is up"
else
/script/bsnldown/amar.sh
fi;

but i want that when it exceute else part script then it should continously ping my gateway if gateway start is start pinging then it should run another script
 
Old 09-23-2015, 08:06 AM   #7
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
If you want to continuously ping your gateway, why are you using 8.8.8.8 in a script?
Sure it is beyond the gateway and is adequate (but ping is not reliable) as a test.

If you want to ping your gateway, then ping the internal gateway IP.
And what the heck is in /script/bsnldown/amar.sh ?
Is that location correct? Looks like it is in the /script directory, not one of 'yours' under $HOME/

Read.
Ask.
Repeat.
 
1 members found this post helpful.
Old 09-23-2015, 08:27 AM   #8
amartlk
Member
 
Registered: Sep 2010
Location: Nagpur India
Posts: 347

Original Poster
Rep: Reputation: 1
Thanks for reply

yes it is location /script/bsnldown/amar.sh, yes you are right i need to user gateway for ping test , if ping is not reliable then what is to do for same
 
Old 09-23-2015, 12:36 PM   #9
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,816

Rep: Reputation: 8003Reputation: 8003Reputation: 8003Reputation: 8003Reputation: 8003Reputation: 8003Reputation: 8003Reputation: 8003Reputation: 8003Reputation: 8003Reputation: 8003
Quote:
Originally Posted by amartlk View Post
Thanks for reply
yes it is location /script/bsnldown/amar.sh, yes you are right i need to user gateway for ping test , if ping is not reliable then what is to do for same
Did you not read or understand post #2, where Habitual VERY CLEARLY gave you a link to how to use netcat for this??

Did you not read or understand the MANY scripts/examples you were handed two years ago when you asked this same question???? DO NOT keep asking for help or handouts, if you're not going to show any effort of your own.
 
Old 09-28-2015, 07:23 AM   #10
amartlk
Member
 
Registered: Sep 2010
Location: Nagpur India
Posts: 347

Original Poster
Rep: Reputation: 1
Thanks at alast i created a script which is running sucesfully
 
Old 09-28-2015, 08:23 AM   #11
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Glad you worked it out.
 
Old 09-28-2015, 09:20 AM   #12
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,816

Rep: Reputation: 8003Reputation: 8003Reputation: 8003Reputation: 8003Reputation: 8003Reputation: 8003Reputation: 8003Reputation: 8003Reputation: 8003Reputation: 8003Reputation: 8003
Quote:
Originally Posted by amartlk View Post
Thanks at alast i created a script which is running sucesfully
Great...but since you've been here for five years now, a script should have been pretty simple. And since you came to this site asking for help, why don't you do as you've been asked several times, and post what you have written, so that OTHERS can be helped as well???

You have said many times in the past that things worked, but haven't ever come back and shared what the solution was. If you come to the community for help, you should also be giving BACK to that community, rather than just asking for handouts.
 
1 members found this post helpful.
Old 09-29-2015, 05:58 AM   #13
amartlk
Member
 
Registered: Sep 2010
Location: Nagpur India
Posts: 347

Original Poster
Rep: Reputation: 1
Thanks guru

#!/bin/bash
if ping -q -c 1 -w 1 local gateway ip >/dev/null; then
echo "ipv4 is up"
else
/script/bsnldown/amar.sh
fi;

the else part script location is /script/bsnldown/amar.sh here i change gateway
 
Old 09-29-2015, 07:47 AM   #14
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,816

Rep: Reputation: 8003Reputation: 8003Reputation: 8003Reputation: 8003Reputation: 8003Reputation: 8003Reputation: 8003Reputation: 8003Reputation: 8003Reputation: 8003Reputation: 8003
Quote:
Originally Posted by amartlk View Post
Thanks guru

#!/bin/bash
if ping -q -c 1 -w 1 local gateway ip >/dev/null; then
echo "ipv4 is up"
else
/script/bsnldown/amar.sh
fi;

the else part script location is /script/bsnldown/amar.sh here i change gateway
Ok...seems like a VERY simple script, and it's hard to know why, after five years, you'd need help writing this, especially since you were given much advice on pretty much the same thing two years ago.

Also, you were told several times in this thread, that ping IS NOT the best tool to use for this, and were given others, with examples. If you're going to ignore the advice you've been given, there isn't much point in asking someone else. Glad it's working...good luck.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
KVM on Redhat 5.7: KVM can ping outside network, outside network can't ping KVM svandyk Linux - Networking 1 09-23-2011 06:45 AM
I cannot ping with command 'ping IP' address but can ping with 'ping IP -I eth0' sanketmlad Linux - Networking 2 07-15-2011 05:32 AM
can ping network computer, cannot ping google.com (help needed) ben_build#2.1.0 Linux - Wireless Networking 23 11-07-2010 12:55 PM
Network Manager Says There's A Network Connection When I Can't Ping Anything resuni Linux - Laptop and Netbook 3 06-11-2010 07:25 AM
Can ping network but can't ping any internet ip when I hard set the ip Streme Linux - Wireless Networking 4 04-13-2004 09:18 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 02:36 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