MT FIRST BASH SHELL SCRIPT ..

This  script pings every ip address in a subnet and outputs the status of that ip whether that  particular ip is assigned to a device or not.

STEPS:::::::

step 1-------

open a new file(here i am using nano ) 



Now write the first line as : #!bin/bash

This helps the shell to recognise the file as a script.

Now you can add  comments just by putting "#" symbol before your comment


.

step 2-----

Write your script 

Here i am  using For loop since, i have to ping multiple times 

here i also used exit status. Exit status tells whether the previous command was successfull or failled with any error. 0 means the command was succesfull and 1-255 any number in this range means an error(command failed to execute or unsuccessfull)

In ping command 0 means there was a reply from ip address and 1 means no reply, rest may be for other network errors.

Here to minimize time i used -c and -w options in ping command.

-c is used to terminate ping after mentioned number of packets send

explanation in manual of ping

-w is used to set waiting time for reply.

                                                              explanation in manual of ping


THIS IS A BASIC ONE::

                                                       here i redirected ping  just to avoid its output..



THIS IS A NESTED  SCRIPT(gives a user understanding output)::::



step3-----

Now its time to make the script executable

use  chmod  command




step4-----

Run the script!!!

you can run script by command:  "bash nameof thescript"

output for basic script----


output for nested script-----


--------------------------------------------------THE END----------------------------------------------------------




Comments

Popular posts from this blog