I'm trying to create a script for seeing if a host is alive, and depending on the ammount of packet loss, send an mail+sms to warn if the host seems to be dead.
The script i'm trying to use is:
No matter if packet loss reported is 0 or 100%, the script reports the host as dead.
1. Strip off the percent sign. The shell can't calculate with this - it doesn't know what % is in terms of arithmetics, ie. write a plain 25.
So in the line
See the man page for your shell for details. (( )) is used for arithmetic evaluation so is more suited to calculations and numeric comparisons. [[ ]] is used for conditional expressions, which includes some numeric stuff but is also useful for matching strings, testing for the presence of files, directories, and other types of devices, etc. If you were to use [[ ]] the syntax would be:
Thanks for your help, it means a lot to me in my learning.
Now I'm stuck again, and i don't know how to solve this problem. =(
I want to put the hostname as a agument when running the script. Like:
script.sh -remote host.name
In this case, the hostname would be $2, but, when i do
it fails.
It seems that using $2 inside the variable doesn't work...
Can anyone please explain to me why it doesn't work, and how to get what i want to work?
I've been trying for some hours now, but I can't find any sollution, nor an answer to why it doesn't work. =(
help with bash script!
im am working on this script to make sure my server will stay online, so i made this script..
HOSTS="192.168.138.155"
COUNT=4
pingtest(){
for myhost in "$@"
do
ping -c "$COUNT" "$myhost" &&return 1
done
return 0
}
if pingtest $HOSTS
#100% failed... (4 Replies)
Hello all. Let me qualify my question by saying that I am struggling with how to ask the question I am semi green but have no issue reading up if pointed in the right direction. Please be gentle!
A RHEL server 6.2. Hosts a statistical application that has some web apps and batch programming... (0 Replies)
Hi All,
I have the requirement where am pinging the server and matching the IP address with the existing IP address. Below code is returning me the IP address and my requirement is i have to see that also whether it is pinging or not
PING useipapd01 (172.22.32.87) 56(84) bytes of data.
64... (1 Reply)
Hi
I am using perl to ping a list of nodes - with script below :
$p = Net::Ping->new("icmp");
if ($p->ping($host,1)){
print "$host is alive.\n";
}
else {
print "$host is unreacheable.\n";
}
$p->close();... (4 Replies)
Hello All,
i would like to start ping command and the result should contain also Timestate.
this i'm able to do with following command :
ping HOSTNAME | perl -nle 'print scalar(localtime), " ", $_'
or
ping HOSTNAME | awk '/time\=(+\.{2}) ms /^+ bytes from / { "date" | getline pong;... (1 Reply)
Hi,
I develop simple animation ping script on Solaris Platform. It is like Cisco ping.
Examples and source code are below.
bash-3.00$ gokcell 152.155.180.8 30
Sending 30 Ping Packets to 152.155.180.8
!!!!!!!!!!!!!.!!!!!!!!!!!!!!!.
% 93.33 success... % 6.66 packet loss...... (1 Reply)
:confused:Hi,
In linux if ping to a system from a linux server it shows ping time=0.120ms
how we can achive this in aix. i need this for a latency check.
Thanks in advance. (5 Replies)
Dear guys,
I don't know the response of a for loop in this situation:
suppose that file1 is an empty file.
and i make a for loop as :
for i in `cat file1`
What will be the response of the for loop:
1- will an error message apear
2- or the for loop simply will not run,and it will escape... (2 Replies)
Hi All
We have one SCO Server here and it never gives us any trouble. Until Now!! Well its not earth shattering but we have one user who is complaining of a very slow response time when changing to his Home Directory. Other users who have similar profiles are OK. I have su'd to this user and I can... (0 Replies)