[Dshield] CAUTION email about shell scripting...

Esler, Joel - Contractor joel.esler at rcert-s.army.mil
Wed Oct 13 13:54:32 GMT 2004


Shell scripting..  I know this may not be the best place to ask this
question, however, I always get great answers from this list..

----------------------begin-------------------

#!/bin/bash

ps aux | grep "ssh -C -p 9428 -R" | grep -v grep

if [ $? -ne 0 ]; then
        ssh -C -p 9428 -R 1521:localhost:1521 -R 3306:localhost:3306
<ip> /snort/startup.sh
else
        sleep 20; ssh -C -p 9428 -R 1521:localhost:1521 -R
3306:localhost:3306 <ip> /snort/startup.sh
        mail -s "Snort tunnel error" foo at foo.com < /snort/cito.error
fi

----------------------end-----------------------


I want the script to connect to the box and run the startup.sh script,
if it faults (can't establish the connection, something wrong with the
script on the the box etc...) I want it to wait a bit (20 seconds) then
try again, and if it STILL fails...  Then email..  I'd like for it to do
it three times (am I doing this correctly?)

Joel



More information about the list mailing list