Sponsored Content
Top Forums Shell Programming and Scripting Scripting with arguments for ping command Post 302944899 by Roggy on Saturday 23rd of May 2015 09:04:31 AM
Old 05-23-2015
Scripting with arguments for ping command

This is the script I already have but I have problems with two arguments
the first argument -t , I want to count 200 by the last digit of the IP address for example when I run the script ./ping.sh -t 17, the output would be
Code:
192.168.0.217 is up

The second arguments --up won't work. Could anybody help me please with these two arguments?
Code:
#!/bin/bash

while [[ -n "$@" ]]
do
    case "$1" in

    -h|--help)
    Extension=1
    shift
    ;;

    -XX-YY)
    Extension=2
    shift
    min=$1
    shift
    max=$1
    shift
    
    ;;

    --up)
    Extension=3
    shift
    end=$1
    shift
    ;;
    esac
done

if [ "$Extension" -eq 1 ] ; then

    echo "dit is de help"

fi


if [ "$Extension" -eq 2 ] ; then

for ((n=$min ; n<=$max ; n+=1))
do
ip=192.168.129.$n
if ping -c 1 -w 1 ${ip} > /dev/null 2> /dev/null >> logping.txt; then
echo "${ip} is up"
else
echo "${ip} is down"
fi
done


fi

if [ "$Extension" -eq 3 ] ; then

         
  
               ip=192.168.129.$end
                if ping -c 1 -w 1 ${ip} > /dev/null 2> /dev/null >> /logping.txt; then
                        echo "${ip} is up"
                       
                fi
     
fi


Last edited by rbatte1; 05-26-2015 at 12:43 PM.. Reason: Added CODE & ICODE tags in main paragraph. Corrected spelling, grammer and case.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

About ping command

Hi! I have small problem. I want to ping a server and the result shouldn't be printed in the browser window, just become a value. Here you can see the script that I have: <? $command="ping linux.com -t ttl -c1 | tail -1 | awk '{print $4 \" \" $5}'"; $output = system($command);... (1 Reply)
Discussion started by: Papa Deoo
1 Replies

2. IP Networking

About ping command

Hi! I have small problem. I want to ping a server and the result shouldn't be printed in the browser window, just become a value. Here you can see the script that I have: $command="ping linux.com -t ttl -c1 | tail -1 | awk '{print $4 \" \" $5}'"; $output = system($command); ... (2 Replies)
Discussion started by: Papa Deoo
2 Replies

3. UNIX for Dummies Questions & Answers

Ping command

Hello Everybody: Im the root of the system, I need to grant some limited priviliges user an acess to the ping command so he can ping some IPs with his script. should I add the command to his path?? or what?? Thanks a lot (3 Replies)
Discussion started by: aladdin
3 Replies

4. AIX

Problem with 'ping' command

Hi All, I'm testing ping command on two servers. A,B,C,D are servers From A-->B: ping -c 3 -p ff -s30720 <B IP-Addres> This works fine. From C-->D: ping -c 3 -p ff -s30720 <D IP-Addres> This is NOT working and 100% packe loss :( But if I use 8700 instead of 30720 for packet size... (6 Replies)
Discussion started by: saraperu
6 Replies

5. UNIX for Dummies Questions & Answers

Help on ping command

Hi, I have a list of 500 IP address and need to ping all the IP address. I had written a script to do this and its working if the IP is valid one. If any invalid IP present, the process got hang up. Also I have tried with -c , -I and -w options, its not working. Any one help me on this... (2 Replies)
Discussion started by: Rksiva
2 Replies

6. Shell Programming and Scripting

Help with Ping command.

Hi, I have a shell script, that has to run in putty for days together. So , I need to keep the network server connection alive and running. The execution of shell script shouldn't be interrupted as it produces undesirable results. Can anyone provide me with a script ? (3 Replies)
Discussion started by: angie1234
3 Replies

7. Homework & Coursework Questions

Shell Scripting with Arguments

1. The problem statement, all variables and given/known data: Problem 1: I need to create a shell script the takes three arguments and echo's out "There once was a ____that____who like to_____" The arguments go where the blanks are. Problemt 2: -Do an LS and store the... (4 Replies)
Discussion started by: dw15
4 Replies

8. Shell Programming and Scripting

Shell scripting with passing arguments

Hi All, I am using the script for creating local queue and passing the arguments while running the script as below n=0 while do e=`expr $n + 3` echo 'DEFINE QL('$e') MAXDEPTH('$6') MAXMSGL('$7') DEFPSIST('$8') '$9'' | /apps/mqm_opt/bin/runmqsc $2 n=`expr $n + 1` done Running the... (5 Replies)
Discussion started by: Anusha M
5 Replies

9. UNIX for Beginners Questions & Answers

Beginner at bash scripting - need help with passing arguments

I at the moment, making a simple bash script, capable of setting up an workspace for me, so i don't have to do it manually.. Problem is though i can't seem to provide the bash script any argument, without running into my error checks, checking for input... Here is the code: #!/bin/bash... (7 Replies)
Discussion started by: kidi
7 Replies

10. Shell Programming and Scripting

Ping scripting

This is my first posting here, I haven't found exactly what I'm looking for anywhere else so I'm hoping you all can help. I have a portion of script here that needs to ping two servers, then return whether they are up or down (somehow), and then echo that information. Here is what I have so far. It... (3 Replies)
Discussion started by: Jeffm0342
3 Replies
cm(5)								File Formats Manual							     cm(5)

NAME
cm - cluster monitor for high availability clusters Remarks Cluster operations require the installation of the optional Serviceguard or Serviceguard Extension for RAC software, which is not included in the standard HP-UX operating system. DESCRIPTION
Serviceguard and Serviceguard Extension for RAC are high availability products which provide an environment such that after a failure of a node, services (applications) can be up and running again on another node within a very short amount of time. In addition, Serviceguard Extension for RAC is the enabling software for the Real Application Clusters (RAC). Working with the basic Serviceguard product, Service- guard Extension for Faster Failover allows configuration of clusters for optimized failover. Commands The following set of commands is used to configure a high availability cluster: cmquerycl(1M) cmmakepkg(1M) cmcheckconf(1M) cmapplyconf(1M) The following commands are used to run or halt a cluster: cmruncl(1M) cmhaltcl(1M) cmrunnode(1M) cmhaltnode(1M) cmviewcl(1M) Once a cluster is formed, the following commands are provided for manual operation on high availability packages: cmrunpkg(1M) cmhaltpkg(1M) cmmodpkg(1M) The following commands are used within a package control script to control the services and networks configured for a package: cmrunserv(1M) cmhaltserv(1M) cmmodnet(1M) A command is provided to aid in migrating from a SwitchOver/UX configuration to a Serviceguard cluster: cmmigrate(1M) This command is not applicable with Serviceguard Extension for RAC. SEE ALSO
Managing Serviceguard. Configuring RAC Clusters with Serviceguard Extension for RAC. Requires Optional Serviceguard Software cm(5)
All times are GMT -4. The time now is 04:42 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy