Hey, I'm trying to get comfortable making scripts. Can anyone help give me perfect my script below? Want to make a script that checks if a host is up and if the host isn't up it will make sure openvpn is up and running and try to ping again. If the host is up then it will say success prompt for further directions
read "What is your IP?: IP"
ping -c4 $ip
if the output contains "64 bytes from 10.10.10.x: icmp_seq=1 ttl=* time=* ms"
if not echo "Host is not up"
openvpn username.ovpn
I know this is bad but can someone help perfect PLEASE?
Comments
It is good to practice. What language do you want to use?
I find iterating each step is good practice - then when one bit is working you can move to the next. As you go you will find the most comfortable technique for you.
For example, in bash you could try:
then invoke it with
scriptname.sh IPADDR
Note: https://www.nohello.com/
Happy to help people but PLEASE explain your problem in as much detail as possible! If you say vague things like "It's not working", I cant help. This isn't Twitter so my DMs are always open.
Thank you! I am testing it out now. Will let you know of kinks.
So instead of me having to type the IP every time. How would I sweep 10.10.10.* and have it return which hosts are up if any?
Well, really you could try
nmap -T4 10.10.10.1/24
but it gets a bit more complex now.Note: https://www.nohello.com/
Happy to help people but PLEASE explain your problem in as much detail as possible! If you say vague things like "It's not working", I cant help. This isn't Twitter so my DMs are always open.