Chanthu
Chanthu

Reputation: 834

Error in linux script

I have written the below script to check whether my server running fine or not.But it is not properly working.It always showing Not runing even if it is running fine.Also the telnet in the script is not running working properly .Can any one help?

#!/bin/sh
export smtp=smtprelay.intra.xxx.com:25
Connect_redmine(){
telnet redmine.intra.xxx.com 443 <<EOF
exit 1;
EOF
}

Connect_redmine>/home/ssx00001/log_connect.txt
grep "Connected" /home/ssx00001/log_connect.txt
status=$?
if [ $status == 0 ]; then
echo `date`  "Redmine PROD server is running fine"|mailx -r Redmine@xxx -s "Redmine PROD server is running" [email protected]
else
echo "Redmine PROD server  is not Running"|mailx -r [email protected] -s "Redmine PROD server is not running" [email protected]
fi

Upvotes: 1

Views: 74

Answers (1)

roelofs
roelofs

Reputation: 2170

A couple of questions first:

1] What does redmine do? Is it just a HTTPS server?

2] If [1] is true, can you do a wget of the index page, and use the result of that? It should be a lot easier to parse.

3] Telnetting into a HTTPS server, as far as I know, won't work, because it's not doing any of the handshaking that would be necessary for an SSL connection (which needs to occur before any content will be sent).

Using wget, you can do something like this:

wget https://redmine.intra.xxx.com/index.html

if [[-f "index.html" ] && [ -s "index.html" ]]

then

# The service is live

else

# Something is wrong

fi

Upvotes: 3

Related Questions