Sponsored Content
Full Discussion: Script Testing
Top Forums Shell Programming and Scripting Script Testing Post 302560600 by vbe on Friday 30th of September 2011 09:51:05 AM
Old 09-30-2011
Should you not also close with fi all your if statements? (your indentation is difficult to follow...)

Code:
#!/bin/bash
#Script to Test Connectivity withListen Address & Port Address

#Script Executiong Path
#export $PATH=$HOME:/bin:/usr/bin/:/usr/sfw/bin:/tools:/Production

#Connectivity Test Using TelNet & OpenSsl Connectivity Test
#TEST1=/usr/bin/telnet
OPSS_TEST=/usr/sfw/bin/openssl

# Script name without path
BASENAME=`basename $0`

# Script Location
HOME=/home/myAccount

#OPENSSL TesT Configuration Directory
OPSS_CGI_AB=$HOME/conf/OPSS-Test/OPSS_CGI_ABUSE_LST
OPSS_CGI_XSS=$HOME/conf/OPSS-Test/OPSS_CGI_XSS_LST
OPSS_FTP_SRV=$HOME/conf/OPSS-Test/OPSS_FTP_SRV_LST
OPSS_GEN_SRV=$HOME/conf/OPSS-Test/OPSS_GEN_SRV_LST
OPSS_MIS_SRV=$HOME/conf/OPSS-Test/OPSS_MIS_SRV_LST
OPSS_COMP_SRV=$HOME/conf/OPSS-Test/COM_SRV_LST
OPSS_RPC_SRV=$HOME/conf/OPSS-Test/OPSS_RPC_SRV_LST
OPSS_SRV_DET=$HOME/conf/OPSS-Test/SRV_SRV_LST
OPSS_SMT_PROB=$HOME/conf/OPSS-Test/OPSS_SMT_PROB_LST
OPSS_SNM_SRV=$HOME/conf/OPSS-Test/OPSS_SNM_SRV_LST
OPSS_WEB_SER=$HOME/conf/OPSS-Test/WEB_SRV_LST
OPSS_WINDOW=$HOME/conf/OPSS-Test/WIN_SRV_LST

#The changes will write to OUTFILE

OUTFILE=$HOME/conf/

DATE=`date`


# Functional Usage

usage() {
         if [ "$2" != 0 ]|| [ "$1" != 0 ]
        then
        echo
        echo "  Check USAGE for correct Parameters  "
        echo "   $BASENAME  <OPTION> "
        echo
        echo "OPTION:   -a = Connectivity Test Report for CGI-Abuse Family
                                -b = Connectivity Test Report for CGI-XSS Family
                                -c = Connectivity Test Report for FTP Family
                                -d = Connectivity Test Report for General Cateory
                                -e = Connectivity Test Report for Misc
                                        -f  = Connectivity Test Repport for Compilance Category
                                        -g = Connectivity Test Report for RPC Family
                        -h = Connectivity Test Service Detection
                -i  = Connectivity  Test SMTP Problem
                -j  = Connectivity Test for SNMP
                -k  = Connectivity Test WebServers
                -l   = Connectivity Test to WINDOWs Servers. "
        exit
        fi
        }


connectivityTest () {

#Local Variables
      #
       local STATE="$1"
      #

    case $1 in
        -a|-A) echo "Trying to test ${OPSS_CGI_AB}"
         while read a; 
         do
              echo "------------------------------"
                ${OPSS_TEST} s_client -debug -connect -a
         done  < "${OPSS_CGI_AB}"
         if [ $? != 0 ]
         then
               echo " Connectivity ${OPSS_CGI_AB} : Failed  `$tr` Port Closed "
               else
               echo " Test Succeeded : ${OPSS_CGI_AB}  `$tr` Refer to the Nessus Solution"
               echo "------------------------------"
         fi
         ;;
       -b|-B) echo "Trying to test ${OPSS_CGI_XSS}"
        while read a; 
        do
                echo "------------------------------"
                ${OPSS_TEST} s_client -debug -connect  -b
        done  < "${OPSS_CGI_XSS}"
        if [ $? != 0 ]
        then
               echo " Connectivity ${OPSS_CGI_XSS} : Failed  `$tr` Port Closed "
               else
               echo " Test Succeeded : ${OPSS_CGI_XSS}  `$tr` Refer to the Nessus Solution"
               echo "------------------------------"
        fi
        ;;
     -c|-C) echo "Trying to test ${OPSS_FTP_SRV}"
        while read a; 
        do
           echo "------------------------------"
           ${OPSS_TEST} s_client -debug -connect -c
        done  < "${OPSS_FTP_SRV}"
        if [ $? != 0 ]
        then
               echo " Connectivity ${OPSS_FTP_SRV} : Failed  `$tr` Port Closed "
        else
               echo " Test Succeeded : ${OPSS_FTP_SRV}  `$tr` Refer to the Nessus Solution"
               echo "------------------------------"
        fi
        ;;
    -d|-D) echo "Trying to test $OPSS_GEN_SRV"
        while read a; 
        do
             echo "------------------------------"
             ${OPSS_TEST} s_client -debug -connect -d
        done  < "${OPSS_GEN_SRV}"
        if [ $? != 0 ]
        then
               echo " Connectivity ${OPSS_GEN_SRV} : Failed  `$tr` Port Closed "
        else
               echo " Test Succeeded : ${OPSS_GEN_SRV}  `$tr` Refer to the Nessus Solution"
               echo "------------------------------"
        fi
        ;;
   -e|-E)echo "Trying to test ${OPSS_MIS_SRV}"
        while read a; 
        do
            echo "------------------------------"
            ${OPSS_TEST} s_client -debug -connect -e
        done  < "${OPSS_MIS_SRV}"
        if [ $? != 0 ]
        then
               echo " Connectivity ${OPSS_MIS_SRV} : Failed  `$tr` Port Closed "
        else
               echo " Test Succeeded : ${OPSS_MIS_SRV}  `$tr` Refer to the Nessus Solution"
               echo "------------------------------"
        fi
        ;;
    -f|-F) echo "Trying to test ${OPSS_COMP_SRV}"
        while read a; 
        do
            echo "------------------------------"
            ${OPSS_TEST} s_client -debug -connect -f
        done  < "${OPSS_COMP_SRV}"
        if [ $? != 0 ]
        then
                echo " Connectivity ${OPSS_COMP_SRV} : Failed  `$tr` Port Closed "
        else
                echo " Test Succeeded : ${OPSS_COMP_SRV}  `$tr` Refer to the Nessus Solution"
                echo "------------------------------"
        fi
        ;;
     -g|-G) echo "Trying to test ${OPSS_RPC_SRV}"
        while read a; 
        do
            ${OPSS_TEST} s_client -debug -connect  -g
        done  < "${OPSS_RPC_SRV}"
        if [ $? != 0 ]
        then
                echo " Connectivity ${OPSS_RPC_SRV} : Failed  `$tr` Port Closed "
        else
                echo " Test Succeeded : ${OPSS_RPC_SRV}  `$tr` Refer to the Nessus Solution"
                echo "------------------------------"
        fi
        ;;
     -h|-H) echo "Trying to test ${OPSS_SRV_DET}"
        while read a; 
        do
            echo "------------------------------"
            ${OPSS_TEST} s_client -debug -connect  -h
        done  < "${OPSS_SRV_DET}"
        if [ $? != 0 ]
        then
                echo " Connectivity ${OPSS_SRV_DET} : Failed  `$tr` Port Closed "
        else
                echo " Test Succeeded : ${OPSS_SRV_DET}  `$tr` Refer to the Nessus Solution"
                echo "------------------------------"
        fi
        ;;
    -i|-I) echo "Trying to test ${OPSS_SMT_PROB}"
        while read a; 
        do
            ${OPSS_TEST} s_client -debug -connect -i
        done  < "${OPSS_SMT_PROB}"
        if [ $? != 0 ]
        then
                echo " Connectivity ${OPSS_SMT_PROB} : Failed  `$tr` Port Closed "
        else
                echo " Test Succeeded : ${OPSS_SMT_PROB}  `$tr` Refer to the Nessus Solution"
                echo "------------------------------"
        fi
        ;;
     -j|-J) echo "Trying to test ${OPSS_SNM_SRV}"
        while read a; 
        do
            echo "------------------------------"
            ${OPSS_TEST} s_client -debug -connect  -j
        done  < "${OPSS_SNM_SRV}"
        if [ $? != 0 ]
        then
                echo " Connectivity ${OPSS_SNM_SRV} : Failed  `$tr` Port Closed "
        else
                echo " Test Succeeded : ${OPSS_SNM_SRV}  `$tr` Refer to the Nessus Solution"
                echo "------------------------------"
        fi
        ;;
     -k|-K)echo "Trying to test ${OPSS_WEB_SER}"
        while read a; 
        do
            echo "------------------------------"
            ${OPSS_TEST} s_client -debug -connect  -k
        done  < "${OPSS_WEB_SER}"
        if [ $? != 0 ]
        then
                echo " Connectivity ${OPSS_WEB_SER} : Failed  `$tr` Port Closed "
        else
                echo " Test Succeeded : ${OPSS_WEB_SER}  `$tr` Refer to the Nessus Solution"
                echo "------------------------------"
        fi
        ;;
     -l|-L) echo "Trying to test ${OPSS_WINDOW}"
        while read a; 
        do
            echo "------------------------------"
            ${OPSS_TEST} s_client -debug -connect -l
        done  < "${OPSS_WINDOW}"
        if [ $? != 0 ]
        then
                echo " Connectivity ${OPSS_WINDOW} : Failed  `$tr` Port Closed "
        else
                echo " Test Succeeded : ${OPSS_WINDOW}  `$tr` Refer to the Nessus Solution"
                echo "------------------------------"
        fi
        ;;
          *) usage
        ;;
        esac
        }
exit 1


Last edited by vbe; 09-30-2011 at 11:18 AM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

testing for file size in script

Has anyone got a few tips on how I can test if the file size is 0? I am moving files on a regular basis from one location to another with ftp. The files which are 0 bytes in size we want to discard. Thankyou in advance. (3 Replies)
Discussion started by: Ivo
3 Replies

2. Shell Programming and Scripting

Testing ssh connection from KSH script

Hi. I have a kornshell script that runs on a daily basis as a cron job. Part of what the script does is copy the folder contents from another server to the current server (server where KSH script is running). I have a scp command, as follows: scp $REMOTE_HOST:$REMOTE_FILE_DIR/* $TMP_DIR ... (8 Replies)
Discussion started by: dmilks
8 Replies

3. Shell Programming and Scripting

Testing telnet connections in a script

Hi, I am trying to figure out how to test to see if a server is accepting telnet connections via a script. I have several remote MPE servers that are set in single user mode (and hence not accepting telnet connections), for their backups, I want to try and automate a test (from a unix... (0 Replies)
Discussion started by: dikiee
0 Replies

4. Shell Programming and Scripting

Testing a comand in the script

Hi everyone , i am new to shell scripting and am having some problem to test if this line has been executed well and display a pass message on the screen or fail if not sqlplus XXTEST/$2 <<END > $XXTEST_TOP/log/$0.log @$XXTEST_TOP/admin/sql/XXTEST_SPE1_XX_QUOTE_DETAILS_TBL.sql XXTEST$2... (2 Replies)
Discussion started by: Lutchumaya
2 Replies

5. Shell Programming and Scripting

Testing success of AWK code in KSH script

I need a bit of help here on something simple. I have a KSH script (must be KSH) that needs to change 2 positional variables in a CSV script. The CSV script looks like this: 00001,010109,01/01/2009 00:01:01 00008,090509,09/05/2009 13:47:26 My AWK script will change $2 and $3 based... (4 Replies)
Discussion started by: kretara
4 Replies

6. Shell Programming and Scripting

Testing connection with a script

I have a box that has to start dhcpd when a certain connection is down and stop the dhcpd when the connection is up again. I would appriciate any help making this script: From server A: ping server B if connection is ok then do nothing if connection is not ok then start dhcpd until... (8 Replies)
Discussion started by: KimJensen
8 Replies

7. Shell Programming and Scripting

script to fill up disk space for testing purpose

Hello everyone I am new to this forum I am working on a project and needed a test script to fill up a disk partition /tmp/data to see how the program fails. The system I am working on is a redhat 5.3. Is there anything out there? Thanks. (10 Replies)
Discussion started by: dp100022
10 Replies

8. Shell Programming and Scripting

Package version testing script

I was wondering if anyone already had a script to check rpm packages versions x.x.x or greater. so I could do a: # CheckRpmVersion Somepackage-1.2.3 And would output: whether the package is installed or not and if it was equal to or greater than the version 1.2.3. I know I can pull out... (0 Replies)
Discussion started by: Ikon
0 Replies

9. Shell Programming and Scripting

testing postgres connection in shell script

I have a script that does db query in postgres. I'm trying to put in some error checking in the script. I keep running into the password prompt problem where when invalid credentials/or database is put it, it would prompt me for a password which hangs the script. Is there a way that I can check for... (0 Replies)
Discussion started by: zerofire123
0 Replies

10. Shell Programming and Scripting

Help with extract application logs through shell script in performance testing

Hi Experts, I am new to shell.How to extract logs (Web,APP,Database) using shell in performance testing? Need for webserver logs,app server logs and d/b logs code. Thanks in advance Sree (3 Replies)
Discussion started by: sree vasu
3 Replies
All times are GMT -4. The time now is 12:43 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy