Find the answer to your Linux question:
Results 1 to 4 of 4
Dear Friend I have a file in root directory named as test_all_ping where I have inserted below code to ping multiple IP. Code: for i in $(cat ips.list); do ping ...
  1. #1
    Just Joined!
    Join Date
    Sep 2008
    Posts
    2

    Exclamation create executable file and run that

    Dear Friend

    I have a file in root directory named as test_all_ping where I have inserted below code to ping multiple IP.

    Code:
    for i in $(cat ips.list); do
    ping ${i}
    done
    Is that ok? If yes, please let me know, how can I make that file executable and after that how can I run that to see multiple IP by using the above executable file.

    Appreciate, if you would come back at your earliest.


    Regards
    Pervez

  2. #2
    Linux Engineer Kieren's Avatar
    Join Date
    Aug 2007
    Location
    England
    Posts
    845
    Your script looks okay but you say you have it in your root directory. It would be better to store it in your /home directory or, if you want every user to have access to it then place it in a folder in your path such as /usr/bin

    You can then make your file executable by using the command:

    Code:
    chmod a+x test_all_ping
    You can then run your script by simply using

    Code:
    ./test_all_ping
    Linux User #453176

  3. #3
    Linux Newbie
    Join Date
    Apr 2009
    Posts
    160
    if you put it in /usr/bin you don't need the ./ in the beginning just use test_all_ping

  4. #4
    Linux Guru coopstah13's Avatar
    Join Date
    Nov 2007
    Location
    NH, USA
    Posts
    3,149
    your script has a logic error in it though, you need to read the man page on ping, by default it pings the address infinitely, so in your script you will never ping more than 1 device, and the script will run endlessly pinging that first device.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...