Is it possible to invoke a fex from a shell script?
My shell script will be a scheduled job which would run periodically, when the shell script would fire, it should trigger the webfocus fex.
Any suggestions? A sample code would be of great help.
Thanks in advance.This message has been edited. Last edited by: <Kathryn Henning>,
June 19, 2013, 02:44 AM
electricbright
Sorry I forgot to mention, Our webfocus server is hosted on the same UNIX box which would contain the shell script.
June 19, 2013, 04:43 AM
Twanette
Hi, there are various ways to do this.
The WebFOCUS RESTful Web Services option is probably the best way in WebFOCUS 8.0, but it is a module that you will license. It is also possible to call WebFOCUS procedures via Java.
However, a fairly "simple" mechanism is to call the FOCEXEC using the EDASTART command. EDASTART is located in the WebFOCUS server's bin directory. I prefer the "edastart -f" option. The "edastart -f" option will allow you to call a t3i file with WebFOCUS "command line" commands (i.e. not Dialogue Manager).
If the bin directory is in your path, you should be able to just type "edastart -?" from unix to see the various options. If not, you will obviously need to prefix edastart with the full directory name.
So the first thing would be to create a t3i file in the directory from which you will issue the edastart command. It would contain something along the following lines:
%connect
%begin
EX your_focexec_name
%end
%disconnect
%stop_server
Assuming we call the t3i file something like "mybatchfex.t3i", then you would invoke it as follows:
edastart -f mybatchfex
Once the process has run, it will create a "mybatchfex.t3o" file which will show you what ran.
The main disadvantage of this method is that the focexec runs in its own "space" and not under the control of the WebFOCUS Server - therefore you cannot monitor it via the HTTP (8121) console.
The issue we had with this was running multiple batch jobs at the same time using the edastart -f command. It seemed like they all used the same temp folder. To get around that we enhanced our script to create a temp folder based on the program being run. In our environment, the same batch program is never running more than once at a time, so effectively the temp folder is unique. The script could be modified to add a timestamp to the folder name if a single job needed to be run multiple times at the same time.
This is our .wf_parms file. This sets up environment varible that can be retrived with the FGETENV user written subroutine:
# Set up WebFOCUS paths:
export WFKIDS=/opt/ibi/kids
export KIDSPROD=$WFKIDS/KIDS/prod
export WFAPP=$WFKIDS/ibi/apps
export WFBASEAPP=$WFAPP/baseapp
export WFREPORTS=$WFAPP/reports
export WFTEMP=$WFAPP/temp
export WFMSG=$WFAPP/msgfiles
export WFSCRIPTS=$WFAPP/scripts
# These need to change between Dev, Test and Prod
export WFCLIENT=(your client dns name or ip address)
# Set default folder and file permisions
# File are rw for owner and group and r for universe
# Folders are rwx for owner and group and rx for the universe
umask 002
This is the script yifex.sh:
#!/bin/ksh
. /home/ibikids/.profile
umask 000
#
export EDATEMP=$WFAPP/temp/$1
export EDAPROF=.
export EDAPATH=.
#
# FOCUSFEX holds the program to be run and with the way this is written, the
# program must be in the app path
#
export FOCUSFEX=$1
export KIDSHOME=/home/ibikids
#
# Create temp folder
#
if [ ! -d $EDATEMP ];
then echo '$EDATEMP does not exist...Creating.'
mkdir $EDATEMP
chmod 774 $EDATEMP
else echo '$EDATEMP exists.'
fi
cd $EDATEMP
pwd
#
# EDASTART is environment variable point the edastart
#
$EDASTART -f $KIDSHOME/yifex.t3i
#
# Set environment variable to the current date (YYYYMMDD format) and save execution messages
#
CURRDT=$(/bin/date +%Y%m%d)
mv yifex.t3o $WFMSG/$1.$CURRDT
cd $KIDSHOME
rm $EDATEMP/* 2>/dev/null
rmdir $EDATEMP
This is the yifex.t3i:
%connect
%begin
EX YIFEX
%end
%disconnect
%stop_server
This is the yifex.fex:
-SET &PGM=FGETENV(8,FOCUSFEX,32,'A32');
-SET &PGM=UPCASE(32,&PGM,'A32');
-SET &PGM=TRUNCATE(&PGM);
EX &PGM
-RUN
Using these pieces, we can run any batch program with this command.
. yifex.sh PROGRAM_NAME
PROGRAM_NAME becomes $1 in yifex.sh
We store the message/screen output in a file named program_name.yyyymmdd where yyyymmdd is the run date. This file is used for debugging if there is a problem. We use another job to automatically delete these message files after 30 days.
Hope this helps.This message has been edited. Last edited by: jgelona,
In FOCUS since 1985. Prod WF 8.0.08 (z90/Suse Linux) DB (Oracle 11g), Self Serv, Report Caster, WebServer Intel/Linux.