You are on page 1of 8

Automation Scripts

By Bill Patow

Editor’s Note: Do you have some repetitive tasks you’d like to put on autopilot? Bill Patow has
three CNC-related tasks for which he created tools to automate, thus freeing up his time to delve
into other projects. If starting/stopping/restarting services, dealing with accidental service shut
downs, or heapdumps play a big part of your daily routine, this article offers a discussion on some
techniques and sample code you can use to reduce your time spent on these tedious tasks.

Overview
Have you ever wished you could start/stop/restart all your OneWorld® or EnterpriseOne® services
with a single keystroke? Have you ever made the mistake of shutting down services on your
batch server while there were still batch jobs running? Have you ever had heapdumps occur on
your Application Server and not known about it until it was too late?

• As a CNC consultant, I have found there are certain repetitive tasks, such as the ones
listed above, that are just tedious and time consuming, although certainly necessary. To
make my life a little easier, I created a set of tools that offers a more reliable way to
control, maintain, and monitor OneWorld or EnterpriseOne Implementation across an
entire enterprise. These tools allow you to control and monitor your E1 systems from a
single set of menus, and do things under the covers like making copies of your log files
and cleaning up rogue processes. Automating these tasks can have the following
benefits:

o increase your productivity


o decrease mistakes
o know when your Application Servers are heapdumping
o keep your disk drive from filling up
o help prevent repetition burnout

The tools I created and will be discussing in this article are:

1. Production Control and Maintenance Programs – Control all your E1 systems and
services from a single menu. These are simple DOS scripts that can be implemented in
any E1 Windows environment (they could probably be ported for UNIX as well). A
screenshot of the Main Menu can be seen in Figure 1.

2. SawSMC Agent Services – I converted the SawSMC Agent batch program into a
service using an inexpensive batch conversion program. This allows you to have the
SawSMC Service startup automatically when the systems are started, and allows you to
logoff your session without the SMC Agent dying (a real drawback of this E1 tool).

3. JAS Heapdump Monitoring – This set of scripts periodically checks for heapdumps on
all your JAS servers. If a heapdump occurs, the automated program sends an email to
any email group or list of users that you choose, and moves the heapdump files off your
main Application Server disk drive to the directory of your choice.

Note: I have only implemented these scripts on EnterpriseOne Windows Servers, but they could likely be
ported to UNIX fairly easily. I don’t have programming experience on AS400, and am not certain they would
have as much value on the AS400 platform.

Note: The JAS service stop/start scripts that I created are written for WebSphere Application Server (WAS).
®
I have not, as yet, ported them to Oracle Application Server (OAS), but that should be possible as well.

Copyright© 2009 Klee Associates, Inc. Page 1


www.JDEtips.com
Automation Scripts

Figure 1: Main Menu

Production Control and Maintenance Program Details


This Production Control and Maintenance tool consists of about 12 different programs that
perform the following tasks:

1. View Status: Allows for quick and easy viewing of the status of all your E1 services with
a single keystroke. It also shows any batch jobs running on any of your batch servers.

2. Stop/Start Services: Stop/Start/Restart all your E1 Services – Enterprise Servers, JAS


Servers, HTTP or IIS Servers – from a menu. The benefits are:
a. Saves a lot of time and hassle – you only have to logon to one machine to run
the program, then you go get a cup of coffee while it stops, starts, or restarts all
your E1 services.
b. Warns you if there are any batch jobs running before shutting down services.
c. Saves your old log files and cleans up your log directories.
d. Kills any rogue processes that didn’t die gracefully (a must-have on many
versions of E1).

3. Stop/Start HTTP: Stop/Start/Restart all your HTTP or IIS services. This allows you to
stop just your Web Servers (all of them) with a single command, so you can temporarily
keep users from logging into JAS without having to take down your JAS services.

4. Purge PDFs: Runs the R9861101 and R9861102 from the command line to cleanup
your older PDFs and purge the Job Control Master Table. It also shows you how many
PDFs you had before and after doing the purge.

Copyright© 2009 Klee Associates, Inc. Page 2


www.JDEtips.com
Automation Scripts

5. R92TAM and R98CRTGL: This runs the UBEs that generate full sets of ddict, ddtext,
and glbltbl files, from the command line. It also does all the copy/moving of the ddict and
ddtext files for you, and backs up the originals before creating new ones. Much simpler
than running them manually, plus no mistakes.

6. Disk Space: View the disk space on all your E1 Enterprise Servers, Deployment server,
Workstations, etc.

7. Check Debug: Allows you to see if debug is turned on, on any of the E1 Enterprise
Servers, Deployment Server, Workstations, etc.

8. Check PTF Level: View the current Tools Release levels of all your machines across
your enterprise (handy during a TR upgrade when all environments are not at the same
level), including multi-foundation configurations.

9. View Wrkstns: Shows you who’s logged onto each of your fat clients, and how long
they’ve been idle. Very helpful when you have a pool of machines and need to find out
which ones are available.

Third Party Software Required


To start/stop services on remote machines in the aforementioned scripts requires that you install
the “Windows Server 2003 Administration Tools Pack” (or whichever Tools Pack is appropriate
for your OS level) onto a workstation from which you will run these scripts. The Tools Pack is
available free of charge from Microsoft.

To install the Tools Pack for Windows Server 2003:

1. Download “Windows Server 2003 Administration Tools Pack” onto your Windows XP
workstation or 2003 server, from the following location:

http://www.microsoft.com/downloads/details.aspx?familyid=c16ae515-c8f4-47ef-a1e4-
a8dcbacff8e3&displaylang=en

2. Install the software on your machine. (This takes about ten minutes to download and
install and there are no fees or licenses involved.)

This gives you the sc.exe program that allows you to start/stop services on remote machines.
For example:

sc \\’servername’ query "IBMWAS6Service - AS_JS_91"

will shutdown the port 91 JAS service on machine ‘servername’.

Note: The Windows Service Name of your JAS Service may vary depending on your E1 and
Application Server release. The example above is for WAS 6.0 running on E8.11, SP1.

Copyright© 2009 Klee Associates, Inc. Page 3


www.JDEtips.com
Automation Scripts

Sample Code
The following is a sample of the code I used to start/stop the http servers at one of my clients.

@echo off
set srvname=E1JAS01
cls

:HTTP_SELECT
call crlf 2
echo HTTP Service Control Menu
echo -----------------------------------------------
echo 1 - STOP - Stop Production HTTP Services
echo 2 - START - Start Production HTTP Services
echo 3 - RESTART - Restart Production HTTP Services
echo 9 - Exit
call crlf 1

set http_select=
set /p http_select=Selection:
if '%http_select%'=='1' goto VERIFY
if '%http_select%'=='2' goto VERIFY
if '%http_select%'=='3' goto VERIFY
if '%http_select%'=='9' goto EXIT
call crlf 1
ECHO "%http_select%" is not valid please try again
goto HTTP_SELECT

:VERIFY
if '%http_select%'=='1' set http_select=STOP
if '%http_select%'=='2' set http_select=START
if '%http_select%'=='3' set http_select=RESTART
call crlf 2
echo Are you sure you want to %http_select% HTTP on %srvname%?
call crlf 1
set verify=
set /p verify= Enter Y for Yes, N for No:
if not '%verify%'=='' set verify=%verify:~0,1%
if '%verify%'=='Y' goto %http_select%
if '%verify%'=='y' goto %http_select%
if '%verify%'=='N' goto HTTP_SELECT
if '%verify%'=='n' goto HTTP_SELECT
call crlf 1
ECHO "%verify%" is not valid please try again
call crlf 1
goto verify

:RESTART
:STOP
call crlf 1
echo ----------------------------------
echo STOPPING HTTP Service - %srvname%
echo ----------------------------------

Copyright© 2009 Klee Associates, Inc. Page 4


www.JDEtips.com
Automation Scripts

call crlf 1
sc \\%srvname% STOP "IBMHTTPServer6.0"
call crlf 2
echo please wait...
call wait 30
if '%http_select%'=='STOP' goto END

:START
call crlf 1
echo ----------------------------------
echo STARTING HTTP Service - %srvname%
echo ----------------------------------
call crlf 1
sc \\%srvname% START "IBMHTTPServer6.0"
call crlf 2
echo please wait...
call wait 30

:END
call crlf 4
set /p done= Press Any Key to Exit...

:EXIT

Copyright© 2009 Klee Associates, Inc. Page 5


www.JDEtips.com
Automation Scripts

SawSMC Agent Service Details


This next procedure turns the SawSMC Agent into a Service. This allows you automatic startup
of the agent when the JAS systems are started, and allows you to logoff your session without the
SMC Agent dying (a real drawback of this JDE tool). Currently the agent dies when you logoff
because it’s only a batch program that runs within your session.

Note: Converting a batch program to an executable, then converting the executable to a service
can be a somewhat complicated process, but is worthwhile. I have omitted most of these
instructions for the sake of brevity, but have identified below where the information can be found.

The steps are as follows:

1. After configuring SawSMC (not covered in this document), make a copy of your
SawAgent_saw.smc.bat program.

2. Create an Executable File from the copied SawAgent_saw.smc.bat program. There are
many tools available for converting batch programs to executables. I use one called
QuickBFC, which can be obtained from the following website for a nominal fee (at the time of
this writing is was about $75 USD) for a single license:

https://www.regnow.com/softsell/nph-softsell.cgi?item=9162-
9&ordertype=Business%20License

There are many other programs to convert batch programs to executables; some are
free. The only free ones I was able to find, however, did not give the capability to run the
executable as a service, due to a manual interaction step that was compiled into the
executable (no doubt, so you would buy the licensed version).

3. Convert the Executable program to a Service. Instructions for doing this can be found at:

http://www.tacktech.com/display.cfm?ttid=197

I did have some issues shutting down the new service once I got it running (in fact, the process
would not actually die), so I created another script that starts/stops the new SawSMC services
cleanly. The SawSMC Agent service is a Java process. If you create your SawSMC service on a
machine that has other Java processes running (such as your JAS server, which is where I like to
install my SawSMC agents), you will find it much simpler to selectively kill the SawSMC Java
process if you use a unique userid to start the SawSMC service. The command I use to kill the
process in my script is:

taskkill /S ‘servername’ /FI "username eq ‘username’" /F /IM java.exe

I also recommend setting up two instances of the SawSMC Agent (on separate machines) so that
if one dies (which happens), you’ll still be notified of events and failures.

Copyright© 2009 Klee Associates, Inc. Page 6


www.JDEtips.com
Automation Scripts

JAS Heapdump Monitoring Details

This tool is a set of scripts that checks for Application Server heapdumps on all your JAS servers
as often as you want: I recommend every five to ten minutes. If a heapdump occurs, the main
program sends an alert email to any email group or list of users that you choose. It can also
move the heapdump files so that you do not run out of space and crash the machine. They can
be moved to another drive on the same machine, or to a file share on another server. They can
also be deleted after a certain amount of time.

The program is a simple .bat program that is run every ten minutes (or at what ever interval you’d
like it to run) from the Windows Task Scheduler. A sample program is shown below:

@echo off
rem --Checks for JVM heapdumps and sends email alerts
rem --the sendmail.vbs program requires a program called cscript
rem -- be installed on your machine.

rem - Check for heapdump file(s)


if exist D:\WebSphere\AppServer\installedApps\servername\EA_JS_443.ear\heapdump*
goto exists
goto end

:exists
rem --Send email alert
cscript D:\WebSphere\AppServer\installedApps\ servername
\EA_JS_443.ear\sendmail.vbs

rem --Move heapdumps to a save folder to avoid repeated alerts on same issue
move D:\WebSphere\AppServer\installedApps\ servername \EA_JS_443.ear\heapdump*
D:\WebSphere\AppServer\installedApps\ servername \EA_JS_443.ear\Save\

move D:\WebSphere\AppServer\installedApps\ servername \EA_JS_443.ear\javacore*


D:\WebSphere\AppServer\installedApps\ servername \EA_JS_443.ear\Save\

:end

One way to send emails from a Windows Server is to use a program called “cscript.exe” and
create a simple vbs script to send the email. (Cscript.exe can be downloaded from the internet.)
The section of the script that calls the email script is:

:exists
rem --Send email alert
cscript D:\WebSphere\AppServer\installedApps\ servername \EA_JS_443.ear\sendmail.vbs

This runs the script every ten minutes, sends an email if there are heapdumps (based on whether
if finds heapdump files in this directory), and moves the dump files to another location. The next
time it runs, the entire process starts over.

Copyright© 2009 Klee Associates, Inc. Page 7


www.JDEtips.com
Automation Scripts

Conclusion
As you can see, these scripts, tools, and procedures can make it much easier to maintain and
monitor your OneWorld and EnterpriseOne systems. They also make the job more full-proof and
less monotonous. Your company will save money in the long run because it takes less time to
complete tasks, freeing up your CNC resources to do other things.

About the Author


Bill Patow has nine years of experience as a JD Edwards CNC Administrator. He has worked
for multiple consulting firms, and now owns a company that offers CNC and Database Consulting
and Managed Services. Prior to becoming a CNC Administrator, Bill worked as a UNIX and
Network Systems Administrator for twelve years, and holds a BS in Computer Science. Bill has
done more than 15 JD Edwards implementations and upgrades, including EnterpriseOne 8.12,
Tools Release 8.97, and the new Business Services Server. He is experienced on all JD
Edwards Platforms and Databases. You may contact the author at
JDEtips.Authors@ERPtips.com. Be sure to mention the author’s name and/or the article title.

NO WARRANTY: This documentation is delivered as is, and Klee Associates, Inc. makes no warranty as to its accuracy
or use. Any use of this documentation is at the risk of the user. Although we make every good faith effort to ensure
accuracy, this document may include technical or other inaccuracies or typographical errors. Klee Associates, Inc.
reserves the right to make changes without prior notice.
NO AFFILIATION: Klee Associates, Inc. and this publication are not affiliated with or endorsed by J.D. Edwards &
Company. J.D. Edwards software referenced on this site is furnished under license agreements between J.D. Edwards &
Company and their customers and can be used only within the terms of such agreements. J.D. Edwards is a registered
trademark of J.D. Edwards & Company. JDE and OneWorld are registered trademarks of J.D. Edwards World Source
Company. WorldSoftware is a trademark of J.D. Edwards World Source Company. Klee Associates, Inc. and this
publication are not affiliated with or endorsed by PeopleSoft, Inc. PeopleSoft, the PeopleSoft logo, PeopleTools,
PS/nVision, PeopleCode, PeopleBooks, PeopleSoft EnterpriseOne, and PeopleSoft World are registered trademarks of
PeopleSoft, Inc. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Klee Associates, Inc., is not
affiliated with or endorsed by Oracle Corporation. All other company and product names used herein may be trademarks
or registered trademarks of their respective owners.

Copyright© 2009 Klee Associates, Inc. Page 8


www.JDEtips.com

You might also like