Hi,
I am really struggling to finish of a script I have been assigned.
The script's purpose is to log on to each server defined in an array, determine the Web Server version, and list the directory
beneath the installation directory. In my case, this installation directory is almost always "/opt/IBMHTTPServer" (sometimes "/opt/IBMHttpServer")
Here's a snippet from the code.
Code:
for host in ${Hosts}
do
AssumedDir=$(batch_ssh ${host} "ls -1 /opt")
if [[ ${AssumedDir} = *IBMHTTPServer* ]]; then
ServerInstallDir='/opt/IBMHTTPServer'
else
ServerInstallDir='/opt/IBMHttpServer'
fi
#DirectoryListing=$(batch_ssh ${host} "find ${ServerInstallDir} -type d -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'")
#DirectoryListing=$(batch_ssh ${host} "ls -1 $ServerInstallDir")
DirectoryListing=$(batch_ssh ${host} "ls -1 $ServerInstallDir | while read d; do echo $d ; done")
ServerVersion=$(batch_ssh ${host} "${ServerInstallDir}/bin/httpd -V | awk 'NR < 2'")
echo '<br /><h3>'${host}'</h3>' >> $HTMLFILE
echo '<b>Server Version</b>: ' ${ServerVersion} >> $HTMLFILE
echo '<br /><b>Directory Structure</b><br /> ' $DirectoryListing >> $HTMLFILE
done
#- Email results
html_mail -t "some.body@company.co.uk" -r "noreply@servername" -s "Apache Security Audit" -a "$HTMLFILE"