November 2024
M T W T F S S
 123
45678910
11121314151617
18192021222324
252627282930  

Categories

November 2024
M T W T F S S
 123
45678910
11121314151617
18192021222324
252627282930  

Shell to find directory and execute

#!/bin/bash
KNOWN_PATH="/usr/sbin /sbin /opt/apache2/bin /usr/local/sbin"
HTTPD_DIR=

for path in $KNOWN_PATH; do
    echo "trying $path/httpd..."
    if `ls $path/httpd > /dev/null 2>&1`; then
        HTTPD_DIR=$path
        break
    fi
done

if [ -z $HTTPD_DIR ]; then
    echo "httpd path not found, please enter the path to directory where httpd is"
    echo -n "httpd path : "
    read HTTPD_DIR
fi
HTTPD="$HTTPD_DIR/httpd"

if [ ! -x $HTTPD ]; then
    echo "httpd could not be found, exiting..."
    exit 1
fi
$HTTPD -V

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>