Hi,
Below is my script, which is used to invoke a test using curl command.
#/usr/bin/sh
MAILTO=user@xyz.com
URL='https://myserver.xyz.net/test/dir/test123.tws'
SOAPFILE=/tmp/soap.txt
curl -k -s -S --header 'Content-Type: text/xml;charset=UTF-8' --data @"${SOAPFILE}" "${URL}"
if [ $? -eq 0 ];
then mailx -s "SUCCESS " $MAILTO ;
else mailx -s "Failure " $MAILTO;
fi
and
expected output from the script:
1) If it is successful
<?xml xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xmlns="http://dir/text123.tws"><response>MY test is successful</response><xxxxxxxxxxxxxxxxxxxxx>
2) other than successful
a) <?xml xxxxxxxxxxxxxxxxxxxxxxxxx:Fault xmlns:axis2ns1="http://schemas.xmlsoap.org/soap/envelope/"><faultcode>xxxxxxxxxx1:Server</faultcode><faultstring>Internal Error</faultstring><detail></detail></soapenv:Fault><xxxxxxxxxxxxxx>
b) Virtual Host to handle xxxxxxxxxxx.tws has not been defined.</H1><Bxxxxx5E: A Virtual Host to handle server.xyz.com has not been defined.</H3><BR><I Server</I>
The exit code on this script is always "0".
Even if i receive any of the above 3 output. (success/error/not defined etc)
My requirement is,
I would like to receive an email notification when the command (cURL) in the script fails. (**other than success )
please provide your input, so that i can receive alerts when the command in the script give output other than success.