Difference between revisions of "Useful Scripts"

From WTFwiki
Jump to navigation Jump to search
(Created page with "Script to check a file with hosts in that file. We will be using the ping command, if we can't ping the host we can do some magic; Lets say the file guardfile.txt contains 1...")
 
Line 2: Line 2:
  
 
Lets say the file guardfile.txt contains 1.1.1.1
 
Lets say the file guardfile.txt contains 1.1.1.1
 
+
<pre>
 
#!/bin/sh
 
#!/bin/sh
 
cat /usr/home/anexit/guard/guardfile.txt | while read line
 
cat /usr/home/anexit/guard/guardfile.txt | while read line
Line 19: Line 19:
 
fi
 
fi
 
done
 
done
 
+
</pre>
 
This script was used as a con job when using the an ssh tunnel.  SSH supports tunnels but when they crash there is no mechanism at the time of this writing to keep or bring interfaces back online.  Man SSH and look for;
 
This script was used as a con job when using the an ssh tunnel.  SSH supports tunnels but when they crash there is no mechanism at the time of this writing to keep or bring interfaces back online.  Man SSH and look for;
  
 
SSH-BASED VIRTUAL PRIVATE NETWORKS
 
SSH-BASED VIRTUAL PRIVATE NETWORKS

Revision as of 16:24, 14 January 2019

Script to check a file with hosts in that file. We will be using the ping command, if we can't ping the host we can do some magic;

Lets say the file guardfile.txt contains 1.1.1.1

#!/bin/sh
cat /usr/home/anexit/guard/guardfile.txt | while read line
do
if [ ! -z $line ]; then
PINGCOUNT=2
PING=$(ping -c $PINGCOUNT $line | grep received | cut -d ',' -f2 | cut -d ' ' -f2)
if [ $PING -eq 0 ]; then
echo "Attempting to establish connection..: $line"
sh /etc/netstart
sh /etc/rc.local

else
echo "Connection is live.: $line"
fi
fi
done

This script was used as a con job when using the an ssh tunnel. SSH supports tunnels but when they crash there is no mechanism at the time of this writing to keep or bring interfaces back online. Man SSH and look for;

SSH-BASED VIRTUAL PRIVATE NETWORKS