Link to home
Start Free TrialLog in
Avatar of AIX25
AIX25Flag for United States of America

asked on

AIX -- How do I create a ping shell script

I need help creating a shell script using ping.  I need it to check the network and see if its up every 5 mins. If the script finds the network up, I want it to go back to sleep. However if it finds the network down to check it 3 times in 5 min intervals. By the third check, if the the network is still down to shutdown the server.  
*I am running AIX 5.3
SOLUTION
Avatar of woolmilkporc
woolmilkporc
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of AIX25

ASKER

Ok hopefully it is still open because I like the way you explain things, you make it easy to understand.
Also I ran #gw=$(lsattr -El inet0 | grep route | cut -d"," -f6 | cut -d" " -f1) and nothing came back or no output.

Thank you
The command I gave you just fills the variable 'gw' with an IP address.
You'll have to issue 'echo $gw' to view the variable's contents.

ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
@kishored - thanks for using my 'lsattr' thing. Seems to be useful, right?
@AIX25 - try that piece. Looks sensible, in a way.
 
wmp
 
... I just saw the -r flag of shutdown (=reboot). I think this doesn't make sense regarding your requirement, should it be the same as in your 'ifconfig' question.
Avatar of kishored2004
kishored2004

yes...it should have been shutdown -Fh.....

sorry for the mistake

Thanks...wmp...thanks for the lsattr thingy...hope this solves the problem

Best of luck!
Avatar of AIX25

ASKER

I do not know any shell scripting. Do I copy the script EXACTLY?? Also, would you be able to include where I have to enter my certain ip address or any other significant info based of my server.  One final request, can you give me a short explanation of each line on the script.

Thank you very much
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of AIX25

ASKER

@woolmilkporc:
When I name the script, do I need to put a .ksh extension?
Do I execute the script with ./sample_script or ksh -x sample_script?
Finally, in the inittab, what will I need to put in the script to indicate to the inittabe to execute the sample_script??

Thank you!
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial