script
Hi
i have centos 5.3 installed on server i want to write a script which will check dns ips i.e 214.253.255.231 and 214.253.255.236 is pinging continously if both ips are not pinging then i want to run another .sh file can you pls assist me in same |
What do you want to achieve from this? Whats the purpose?
|
amartlk,
what exactly do you want to accomplish ? 1) do you want both ip's to be pinged by another one ? 2) OR both ip's should ping each other ? I would like to help provided you give more details !! regards, nm |
Hi
these are the 2 dns ips address of isp i want only ping this 2 ips should ping from my server if both are not pinged the i run one sh file which we restart adsl and my net is working now i do it manually |
Please show us what code you've done so far
|
Code:
ping -c1 <ip> || FixTheInternet.sh Code:
ping -c1 <ip> || dns1=1 && dns1=0 |
Thanks for reply
it is ok as below where below are 2 ip of dns ping -c1 <214.253.255.231> || dns1=1 && dns1=0 ping -c1 <214.253.255.236>|| dns2=1 && dns2=0 (( "$dns1" == "0" && "$dns2" == "0" )) || FixTheInterWebs.sh |
no, remove < and >
<ip> and <ip2> were intended as 'markers' Code:
ping -c1 214.253.255.231 || dns1=1 && dns1=0 while I'm at it, a re-write Code:
for ip in 214.253.255.231 214.253.255.236;do |
#!/bin/bash
for ip in 214.253.255.231 214.253.255.236; do ping -c1 $ip || ( FixTheInterWebs.sh; break ) done is this correct now |
@amartlk: Have you tried running Firerat's examples?
The only way to learn anything is to try to understand what's going on and play around with the given examples. If there's something specific about the code you don't understand we can/will explain it to you. |
Hi
ya i want to understand the flow of code thats why i ask you |
Quote:
|
Quote:
the examples I have given are not difficult lets ignore the second one for now, and look at what the first is doing Code:
ping -c1 214.253.255.231 || dns1=1 && dns1=0 Code:
ping -c1 214.253.255.231;dns1=$? there is not much else I can type about this there are a number of ways to do it anyway, back to my broken logic Code:
for ip in 214.253.255.231 214.253.255.236; you want to Fix the Interwebs if both dns servers are 'down' |
All times are GMT -5. The time now is 12:36 AM. |