Skip to Content

When doing an upgrade with SAP’s EHPi tool have you ever wondered how to use the Alert functionality? Wouldn’t it be nice if you could receive an email when your installer encountered an error? The Alert functionality of the EHPi installer will run a program when the installer encounters an alert situation. This happens whenever the installer stops for interaction with the user or on an Error. Perfect for those nights where you want to get a bit of sleep but still have peace of mind that the installer is chugging along.

Here is an example of what an alert looks like (Click to enlarge):

AlertScreenshot1.png

To set up the alert functionality, you’ll need to write a shell script. Here is what my script looks like:

Alerter.sh – Shell script to send alerts from EHPi

#!/bin/bash

# ****************************************

# Script for alert SAP install triggering

# By Joe Markgraf

# ****************************************

# Configure mailx to send e-mails

#FROM_ADDRESS – indicates the e-mail sender

#SUBJECT – subject of the e-mail

#EMAIL_ADDRESS – indicates the e-mail receiver

#BODY – body of the e-mail

#ATTACHED_FILE – file to be attached to e-mail

FROM_ADDRESS=”EHP_INSTALLER@EXAMPLE.COM

SUBJECT=”EHP Installer ALERT!”

EMAIL_ADDRESS=”joe@example.com

BODY=”EHP Installer ALERT!”

ATTACHED_FILE=”/tmp/Alert.txt”

#If you want to send an e-mail using mailx, use the following command:

#echo “$BODY” | mailx -r “$FROM_ADDRESS” -s “$SUBJECT” “$EMAIL_ADDRESS”

#If you want to attach the file with the alert message, specify the path to the alert file.

#The absolute path to the alert file should be the same as in the alert view.

cat “$ATTACHED_FILE” | mailx -r “$FROM_ADDRESS” -s “$SUBJECT” “$EMAIL_ADDRESS”

There are a few things that you might need to tweak on yours. First, I’m using the bash shell for my script. SAP installations run on the C shell so you may not have a bash shell installed. If that is the case, you can either install bash shell or alter the script so that it’ll work with C shell. Second, you may be using a different program to send emails. We use mailx, but some systems use sendmail, postfix, or any other number of mail commands. You can test to see if which commands work by doing a google search on “send mail command line” and then trying to send a test message to yourself.

If you look at my script, it’s mostly comments with one line of actual code. That line of code is:

cat “$ATTACHED_FILE” | mailx -r “$FROM_ADDRESS” -s “$SUBJECT” “$EMAIL_ADDRESS”

What it’s doing is mailing the alert file as the body of an email. If you can figure out the syntax for your mail command then you’ve got it. If you have trouble, your best bet would be to ask your OS admin for help with the script. 

/wp-content/uploads/2012/10/ehpi_alerter_144806.png

As for config in the EHPI gui – You’ll need a place to put the script, as well as a temporary location for the EHPI installer to write a file with a description of the errors. I use /tmp and just create a file called Alert.txt. I store the script in the same location that I have the installer files for the EHPI installer.

To set this up, you’ll need to specify where your script is, along with where your alert file is. Make sure the SIDADM user has read/write access to those areas and you’ll be good. The delay controls how long the installer waits until sending an email. I set it long enough so it doesn’t fire them off when I’m actually watching the installer. Finally, set active turns the functionality on or off. You’ll want to hit the test button to make sure it’ll fire off an email. You should get an email within a minute or two of hitting the button. If not, check to see if the alert file was written to where you specified and that you’ve got the syntax right on your send mail command.

Feel free to leave comments or questions. I am by no means an expert so input/corrections are welcomed by those who are.

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply