Record and re-use keystrokes

We have a FORTRAN program that creates a report for our client. The client makes a number of selections as to what will appear on the report. However, the client has to repeat this everytime the report is run. I am trying to find a way to record what they've selected (their keystrokes) in UNIX and save it so that they can use a shortcut to re-run an identical report without having to re-select everything. I'm rather new to UNIX, so any input would be appreciated.

The simplest approach is to feed those parameters into the FORTRAN code using a shell script. The shell script can write those parms to a file and reuse them.

So in effect the user can rerun any report that has run in the past.

If you give us a sample of the parameters required, we can start a simple template script for you to tinker with. And no you don't need a keylogger for this.

Thank you for the quick response. Sorry it took so long to reply. The problem is that the parameters as determined by the client, are coming into the script from a GUI called winFAST. So we will have to parse out what we need and leave the GUI code out of the script. Then we can pass them back? The user input determines what is put on the report, and the FORTRAN code is using the input values to determine the direction of the the report detail, format and what database file information to retrieve from different database files. Do you know ISAM?

Ok. whoa.

What UNIX /linux are you using?

Winfast, if it is a GUI, still has to talk to something. A shell script is an executable object, just like compiled FORTRAN. It can talk to the shell script, the shell script takes over for the GUI. We basically have an interposing object. The shell script.

The parameter sets for reports have almost always been up to the customer/clients. I don't see a problem. Does somebody in your shop know enough about UNIX to log on to the command line? Or into some desktop GUI like Gnome? If this is not the case you are as you seem to think: doomed in this endeavor.

And I don't see why ISAM is an issue, except for the cost of commercial ISAM packages.

Unix is on IBM AIX version 5100-04. WinFAST (there is a website: gowinfast.com) is sort of a Unix covering. In-house, we only use the AIX editor, not the GUI. While the client is entering via the GUI, they are really sending info, loading the FORTRAN variables with their selected values, and their movements in WinFAST (i.e. which menus they access and which choices they make) are recorded in a file. That is the file that has all that extraneous GUI code. So I'm thinking that we should be able to parse that information from the file and feed it back to a ksh script and save the script so that the client can access it again? I think this is what you meant, if I'm understanding you correctly...

Can you show us, backed by some samples/scenarios, what the program needs (and gets)? Does it get command line parameters, does it read values, from where (terminal, file, ...)?

For example, the client selects this custom report via a radio button on the GUI. This calls the FORTRAN program that creates the report. The client then selects which fields they want on the report. They make the selection via a grid, which is created from the same FORTRAN program. The choices made (i.e. emp name, address, etc.) are fed back to the FORTRAN program - it is basically the same as asking a question on the terminal and reading in the response. Based on various choices the client makes, the FORTRAN program determines the layout of the report and includes those items that the client has chosen. WinFAST is basically a pass-thru to Unix.

OK, let me phrase it differently: can that program be run from the command line giving the results desired? If yes, I could imagine ways to automate that, if no you may be stuck with that GUI and have to look for key or gesture loggers within that GUI.

The program could be run from the command line if the user knew what to enter as the GUI returns, for instance - the GUI user could push an 'ok' button while the command line user would have to type in 'ok'. So, effectively, we would have to get those "returns", whether it be choices of field or simply a 'yes', 'no', or 'ok', from the user log file into a ksh script and have the program react appropriately to the input. Make more sense?

Exactly, that was the idea. Collect a bunch of commonly run reports with their parameters, put those into a menu script and have the users select the menu item they want for that day.

But it would make more sense to capture the output of the gui than the keystrokes it needs to generate that output. Then you wouldn't need the GUI every time. Probably much easier to capture the output than the keystrokes in any case.

We can capture the output from the GUI (which is the input to the program, I suppose). This info is written to a file; problem is, since this GUI is just a passthru to Unix, what ends up in the file is every bit of the GUI code, from beginning to end. So whatever the user sees in the GUI is, in the background, written on the command line "behind" it. So, if I look at that file afterward, I see everything from "Welcome" to the selections made to the grids that are loaded etc. So you see, it's not simply their selections that I can pass back. I would have to parse them out of the file, which might take some work, but then I'm thinking I could pass them to the script and add a button to the GUI that would essentially run the program using the values in the script. The WinFAST GUI is all client-side and all they can see and use. It's something I had never heard of until I started working here. More info gowinfast.com.

It's going to be way more straightforward to parse a file than hijack and replay an xterm. Terminals are built to avoid that kind of snooping. If you show us sample input and output (with confidential stuff blanked of course) we can probably show you how.

Can't you see the program parameters like when using the -f option to ps , or in the /proc file system?

Not that this will make much sense, but this is the file recording the screen layout that the client sees as well as their selections and the resulting file (a .csv file) shown near the end. Wherever you see "grid", it is a popup grid with check boxes that the user can select items from for their report. Just so you can see what I'm working with...

OK, vi KAB111301
"KAB111301" 409 lines, 11689 characters
{85;100}(@CDEAUTO-@)
{86;1}
Welcome to PAYMASTER'S RealTime 2004 Payroll System
PAYROLL RUN FOR BEST PAYROLL CO IN RI
11/13/ 012     0:10

{85;100}(@CS,Welcome.dat@)
{86;1}
{85;100}
(@SETC,WS01,BEST PAYROLL CO IN RI         @)(@SETC,WS02,11/13/2012    11:56 AM@)
(@HC,PP11@)(@HC,PP12@)(@HC,PP13@)(@HC,PP14@)(@HC,PP21@)(@HC,PP22@)(@HC,PP23@)(@HC,PP24@)(@HC,RP11@)(@HC,RP12@)(@HC,RP13@)(@HC,IO11@)
(@HC,IO12@)(@HC,IO13@)(@HC,IO14@)(@HC,IO15@)(@HC,IO16@)(@HC,IO16@)(@HC,IO21@)(@HC,IO22@)(@HC,IO24@)(@HC,IO25@)(@HC,IO26@)
{85;100}(@SETC,IO03,             Web Report Portal              @)
{86;0}i
(@HC,AD02@)(@HC,AD03@)
{85;100}(@SETC,AD01,Check stubs are available on the *NEW* Employee Web Portal-call Andrea for more info.@)
{86;0}i
{85;100}
(@HC,AD02@)
{86;1}
{86;1}
FM=File maintenance menu
RP=Reports
QU=Employee and company inquiry screens
PA=Set Priority Access code (RESTRICTED)
~C~A1
~C~A1
~C~A1
~C~TM
{85;100}
(@SC,IO11@)(@SC,IO21@)(@HC,IO15@)(@HC,IO25@)(@HC,IO12@)(@HC,IO22@)(@HC,IO14@)(@HC,IO24@)(@HC,IO16@)(@HC,IO26@)
{86;1}
~F~IO21~TM
{85;100}
(@HC,IO11@)(@HC,IO21@)(@R,http://WWW.CSCPAYMASTER.COM/winpay/WINDOWS USER GUIDE.htm,@)
{86;1}
{85;100}(@CS,Welcome.dat@)
{86;1}
{85;100}
(@SETC,WS01,BEST PAYROLL CO IN RI         @)(@SETC,WS02,11/13/2012    11:56 AM@)
(@HC,PP11@)(@HC,PP12@)(@HC,PP13@)(@HC,PP14@)(@HC,PP21@)(@HC,PP22@)(@HC,PP23@)(@HC,PP24@)(@HC,RP11@)(@HC,RP12@)(@HC,RP13@)(@HC,IO11@)
(@HC,IO12@)(@HC,IO13@)(@HC,IO14@)(@HC,IO15@)(@HC,IO16@)(@HC,IO16@)(@HC,IO21@)(@HC,IO22@)(@HC,IO24@)(@HC,IO25@)(@HC,IO26@)
{85;100}(@SETC,IO03,             Web Report Portal              @)
{86;0}i
(@HC,AD02@)(@HC,AD03@)
{85;100}(@SETC,AD01,Check stubs are available on the *NEW* Employee Web Portal-call Andrea for more info.@)
{86;0}i
{85;100}
(@HC,AD02@)
{86;1}
{86;1}
FM=File maintenance menu
RP=Reports
QU=Employee and company inquiry screens
PA=Set Priority Access code (RESTRICTED)
~C~RP
{85;100}
(@HC,IO11@)(@HC,IO12@)(@HC,IO13@)(@HC,IO14@)(@HC,IO15@)(@HC,IO16@)(@HC,IO21@)(@HC,IO22@)(@HC,IO24@)(@HC,IO25@)(@HC,IO26@)
{86;1}
Miscellaneous Reports Menu
EL=Various employee lists
BD=Birthday list
SN=Employee seniority listings
MP=Various period ending reports
PB=Probationary employee reports
AR=Alternate rate listing
RH=Employee rate history report
HR=Y-T-D hours and earnings report
EO=Equal employment opportunity report (EEO)
MS=Various Y-T-D employee record dumps
GL=General ledger account report
WC=Workers compensation report
CO=Company master profile report
DN=Import complete employee profile information
CD=Import custom employee profile information
C1=Import custom HR profile information
TS=Import custom employee profile, earnings, and deduction information
RT=Return to the main menu
 T;100i(@CS,rpt-main.dat@)
{86;0}1
{85;100}(@HC,ad01@)
{86;1}
{85;100}(@HC,ad03@)
{86;1}
{85;100},(@SETC,RP01, 990  BEST PAYROLL CO IN RI         @)
{86;0}1
{85;100},(@SETC,ad01,HR-Lite keeps all your information available online@)
{86;0}1
{85;100},(@SETC,ad02,Click here for a sample of our *NEW* web based employee portal check stub@)
{86;0}1
{85;100},(@SETC,ad03,Get your payroll reports online using our secure Web Portal- call to setup@)
{86;0}1
{85;100},(@SETC,RP02,11/13/12    12:06PM@)
{86;0}1
~F~RP03~TS
{85;100}(@CS,REPORT1.dat@)
{86;1}
{85;100}(@HC,RP-14A@)(@HC,RP-14B@)(@HC,RP-14D@)
{23;861}
{85;100}(@HC,RP-15A@)(@HC,RP-15B@)(@HC,RP-15D@)
{23;861}
{85;100}(@HC,RP-16A@)(@HC,RP-16B@)(@HC,RP-16D@)
{23;861}
{85;100}(@HC,RP-17A@)(@HC,RP-17B@)(@HC,RP-17D@)
{23;861}
{85;100}(@HC,RP-18A@)(@HC,RP-18B@)(@HC,RP-18D@)
{23;861}
{85;100}(@HC,RP-19A@)(@HC,RP-19B@)(@HC,RP-19D@)
{23;861}
{85;100}(@HC,RP-20A@)(@HC,RP-20B@)(@HC,RP-20D@)
{23;861}
{85;100}(@HC,RP-21A@)(@HC,RP-21B@)(@HC,RP-21D@)
{23;861}
{85;100}(@HC,RP-22A@)(@HC,RP-22B@)(@HC,RP-22D@)
{23;861}
{85;100}(@HC,RP-23A@)(@HC,RP-23B@)(@HC,RP-23D@)
{23;861}
{85;100}(@CREATEDIR,C:\WINFAST\REPORTS@)
{86;1}
{85;100}(@SETC,RP-04,Create a Custom Excel Import File@)(@SETC,RP-01,0990@)(@SETC,RP-02,BEST PAYROLL CO IN RI         @)(@setc,RP-08
,Import contents are determined by your selection in the grid@)
{86;1}
{85;100}(@CS2,field-select-1.dat@)
{86;1}
{85;10}FIELD1GRID^
Employee-Number~
Division                   ~
Department~
Class                      ~
Last-Name~
First-Name                 ~
Middle-Initial~
Employee-Position          ~
Class-Description~
Pay-Frequency-Code         ~
Employee-Status-Code~
EEO-Race-Code              ~
Shift-Code~
Pension-Coverage-Code      ~
EIC-Code~
EEO-Position-Code          ~
Social-Security-Number~
Phone-Number               ~
Password-Priority-Level    ~
Employment-Basis-Code      ~
Date-Record-Changed        ~
Address-Line-1             ~
Address-Line-2             ~
Address-Line-3             ~
City                       ~
State                      ~
Zip-Code                   ~
401k/403b Pension Eligible ~
Actual-Marital-Status      ~
Gender                     ~
State-Taxing-Code          ~
City-Taxing-Code           ~
Federal-Marital-Status     ~
State-Marital-Status       ~
City-Marital-Status        ~
Position-Date              ~
Class-Date                 ~
Date-of-Birth              ~
Date-of-Hire               ~
Date-of-Last-Rate-Change   ~
Employee-Status-Date       ~
Earnings-Method-Code       ~
Workers-Comp-Code          ~
Federal-Exemptions         ~
State-Exemptions           ~
City-Exemptions            ~
Hours-per-Pay-Period       ~
Current-Rate               ~
Previous-Rate              ~
Rate-per-Pay-Period        ~
Date-of-Last-Rate-Change   ~
Date-Last-Check-was-Issued ~
Q/T/D-Gross-Earnings       ~
Y/T/D-Gross-Earnings       ~
Q/T/D-Withholding-Tax-Gross~
Y/T/D-Withholding-Tax-Gross~
Q/T/D-Withholding-Tax      ~
Y/T/D-Withholding-Tax      ~
Q/T/D-Social-Security-Gross~
Y/T/D-Social-Security-Gross~
Q/T/D-Social-Security-Tax  ~
Y/T/D-Social-Security-Tax  ~
Q/T/D-Medicare-Gross       ~
Y/T/D-Medicare-Gross       ~
Q/T/D-Medicare-Tax         ~
Y/T/D-Medicare-Tax         ~
Q/T/D-FUTA-Gross           ~
Y/T/D-FUTA-Gross           ~
Q/T/D-Tip-Earnings         ~
Y/T/D-Tip-Earnings         ~
Q/T/D-EIC                  ~
Y/T/D-EIC                  ~
Q/T/D-3rd-Party-S/S-Gross  ~
Y/T/D-3rd-Party-S/S-Gross  ~
Q/T/D-3rd-Party-S/S-Tax    ~
Y/T/D-3rd-Party-S/S-Tax    ~
Q/T/D-3rd-Party-M/C-Gross  ~
Y/T/D-3rd-Party-M/C-Gross  ~
Q/T/D-3rd-Party-M/C-Tax    ~
Y/T/D-3rd-Party-M/C-Tax    ~
Y/T/D-Other-Compensation   ~
Y/T/D-1099-Earnings        ~
Primary-State-Code         ~
Last-Check-Date-PS         ~
Q/T/D-Gross-Earnings-PS    ~
Y/T/D-Gross-Earnings-PS    ~
Q/T/D-Withholding-Gross-PS ~
Y/T/D-Withholding-Gross-PS ~
Q/T/D-Withholding-Tax-PS   ~
Y/T/D-Withholding-Tax-PS   ~
Q/T/D-SDI-Gross-PS         ~
Y/T/D-SDI-Gross-PS         ~
Q/T/D-SDI-Tax-PS           ~
Y/T/D-SDI-Tax-PS           ~
Q/T/D-SUI-Gross-PS         ~
Y/T/D-Sui-Gross-PS         ~
Y/T/D-1099-Earnings-PS     ~
                           ~
 

{86;1}
~GR~FIELD1GRID~1|2|3|5|6|7
     1     1
     2     0
     2     2
     3     0
     3     3
     4     0
     4     5
     5     0
     5     6
     6     0
     6     7
{85;100}(@CS2HIDE@)
{86;1}
{85;100}(@SC,RP-14@)(SC,RP-14@)(@SETC,RP-14,                             @)(@HC,RP-14A@)(@SETC,RP-14,Do you want to include earnings
 code info in the file?@)(@SC,RP-15A@)(@SF,RP-15A@)
{86;1}
 ! ~F~RP-15A~YES
{85;100}(@SETC,RP-10,Earnings code data to be included@)
{86;1}
{85;100}(@CS2,field-select-2.dat@)
{86;1}
{85;10}field2grid^
01~REGULAR ~Hours
02~OVERTIME~Hours
03~DBLTME  ~Hours
04~VACATION~Hours
05~SICK    ~Hours
06~HOLIDAY ~Hours
07~COMMSN  ~Dollars
08~BONUS   ~Dollars
09~MISCEL  ~Dollars
10~REGULAR$~Dollars
11~TIP HRS ~Hours
12~TIPS    ~Dollars
13~SHFT DIF~Dollars
15~MED125  ~Dollars
16~DENTL125~Dollars
17~G-T-L   ~Dollars
18~AUTO-EOY~Dollars
19~HLTH-S  ~Dollars
20~HAPPY   ~Dollars
25~3PTYSICK~Dollars
{86;1}
{86;1}
~GR~FIELD2GRID~1|2|4|5|6
     1     1
     2     0
     2     2
     3     0
     3     4
     4     0
     4     5
     5     0
     5     6
{85;100}(@CS2HIDE@)
{86;1}
{85;100}(@SC,RP-15@)(SC,RP-15@)(@SETC,RP-15,                             @)(@HC,RP-15A@)(@SETC,RP-15,Do you want to include deductio
n code info in the file?@)(@SC,RP-16A@)(@SF,RP-16A@)
{86;1}
 ! ~F~RP-16A~NO
{85;100}(@CS2HIDE@)
{86;1}
{85;100}(@SETC,RP-20,Formatting report...please wait@)
{86;1}
     1    15    29    43    57    71
{85;6}<appdir>\REPORTS\EMPLOYEES.CSV^
Employee-Number,Division,Department,Last-Name,First-Name,Middle-Initial,REGULAR --HOURS,REGULAR --DOLLARS,OVERTIME--HOURS,OVERTIME--
DOLLARS,VACATION--HOURS,VACATION--DOLLARS,SICK--HOURS,SICK--DOLLARS,HOLIDAY --HOURS,HOLIDAY --DOLLARS,
1,0,1,ADAMS,DON, , 1942.50 ,32536.89 , 50.50 ,422.95 , 76.00 , 1273.00 , 48.00 ,804.00 , .00 , .00 ,
3,0,4,SIMPSON,JOE,P, 1920.00 ,79560.00 , .00 , .00 , .00 , .00 , .00 , .00 , .00 , .00 ,
4,0,1,CHAPLIN,ALBERT , , 1412.00 ,17650.00 , .00 , .00 , 14.84 ,185.58 , .00 , .00 , .00 , .00 ,
5,0,2,GOOD ,JOHN ,B, 1954.00 ,29310.00 , .00 , .00 , 25.99 ,389.99 , 40.00 ,600.00 , .00 , .00 ,
6,0,1,ORTIZ,DAVID, , .00 , .00 , .00 , .00 , .00 , .00 , .00 , .00 , .00 , .00 ,
7,0,1,RAMIREZ,MANNY, , .00 , .00 , .00 , .00 , .00 , .00 , .00 , .00 , .00 , .00 ,
8,0,3,JOHN ,HECTOR , , 15.00 , 43.35 , 15.00 , 21.69 , .00 , .00 , .00 , .00 , .00 , .00 ,
9,0,5,MCMARTIN ,CATHRINE , , 1920.00 ,24000.00 , .00 , .00 , .00 , .00 , .00 , .00 , .00 , .00 ,
 10,0,2,SMITH,ADAM , , 1144.50 ,12529.50 ,4.00 , 22.00 ,109.35 , 1163.10 , .00 , .00 , .00 , .00 ,
 11,0,6,TELL ,WILLIAM, , 1925.50 ,28882.50 ,141.00 , 1057.50 , 64.00 ,960.00 ,8.00 ,120.00 , .00 , .00 ,
 12,0,2,FRANCONE ,TERRY, , .00 , .00 , .00 , .00 , .00 , .00 , .00 , .00 , .00 , .00 ,
 13,0,4,ROSE ,RONNIE , , .00 , .00 , .00 , .00 , .00 , .00 , .00 , .00 , .00 , .00 ,
 14,0,5,HALL ,JOHN , , .00 , .00 , .00 , .00 , .00 , .00 , .00 , .00 , .00 , .00 ,
 15,0,6,HALLMARK ,MARY , , .00 , .00 , .00 , .00 , .00 , .00 , .00 , .00 , .00 , .00 ,
 16,0,6,BARNSIDER,HARRY, , .00 , .00 , .00 , .00 , .00 , .00 , .00 , .00 , .00 , .00 ,
{86;1}
{85;100}(@R,C:\WINFAST\REPORTS\EMPLOYEES.CSV,@)
{86;1}
FILE "EMPL.CSV" IS READY WITH  15 EMPLOYEES
{85;6}<appdir>\combo\depts.txt^00--001;OFFICE
00--002 ;MANAGEMENT
00--003 ;WAITSTAFF
00--004 ;SALES
00--005 ;WAREHOUSE
00--006 ;SERVICE
{86;1}
{85;6}<appdir>\combo\state.txt^CT;-State Code
MA;-State Code
RI;-State Code
{86;1}
~~
{85;100}(@CDEAUTO-@)
{86;1}
Welcome to PAYMASTER'S RealTime 2004 Payroll System
PAYROLL RUN FOR BEST PAYROLL CO IN RI
11/13/ 012     0:10
5,0,2,GOOD ,JOHN ,B, 1954.00 ,29310.00 , .00 , .00 , 25.99 ,389.99 , 40.00 ,600.00 , .00 , .00 ,
6,0,1,ORTIZ,DAVID, , .00 , .00 , .00 , .00 , .00 , .00 , .00 , .00 , .00 , .00 ,
7,0,1,RAMIREZ,MANNY, , .00 , .00 , .00 , .00 , .00 , .00 , .00 , .00 , .00 , .00 ,
8,0,3,JOHN ,HECTOR , , 15.00 , 43.35 , 15.00 , 21.69 , .00 , .00 , .00 , .00 , .00 , .00 ,
9,0,5,MCMARTIN ,CATHRINE , , 1920.00 ,24000.00 , .00 , .00 , .00 , .00 , .00 , .00 , .00 , .00 ,
 10,0,2,SMITH,ADAM , , 1144.50 ,12529.50 ,4.00 , 22.00 ,109.35 , 1163.10 , .00 , .00 , .00 , .00 ,
 11,0,6,TELL ,WILLIAM, , 1925.50 ,28882.50 ,141.00 , 1057.50 , 64.00 ,960.00 ,8.00 ,120.00 , .00 , .00 ,
 12,0,2,FRANCONE ,TERRY, , .00 , .00 , .00 , .00 , .00 , .00 , .00 , .00 , .00 , .00 ,
 13,0,4,ROSE ,RONNIE , , .00 , .00 , .00 , .00 , .00 , .00 , .00 , .00 , .00 , .00 ,
 14,0,5,HALL ,JOHN , , .00 , .00 , .00 , .00 , .00 , .00 , .00 , .00 , .00 , .00 ,
 15,0,6,HALLMARK ,MARY , , .00 , .00 , .00 , .00 , .00 , .00 , .00 , .00 , .00 , .00 ,
 16,0,6,BARNSIDER,HARRY, , .00 , .00 , .00 , .00 , .00 , .00 , .00 , .00 , .00 , .00 ,
{86;1}
{85;100}(@R,C:\WINFAST\REPORTS\EMPLOYEES.CSV,@)
{86;1}
FILE "EMPL.CSV" IS READY WITH  15 EMPLOYEES

Now please explain which parts you want to extract so we can show you how to extract it...

Anywhere a choice is made; for example:

~GR~FIELD1GRID~1|2|3|5|6|7

means the user has chosen the fields from the grid (field 1,2,3,5,6,7) to include in the report. The user then makes other choices, for example, their response to

(@SETC,RP-14,Do you want to include earnings code info in the file?@)(@SC,RP-15A@)(@SF,RP-15A@)
{86;1} is  ! ~F~RP-15A~YES

, and their response of 'YES' brings up another grid from which they choose fields. Make sense?

You're going to have to be a lot more specific. We don't know this program; we can't tell when a choice has been made.

1 Like

That's what I meant about the WinFAST extraneous information; For all intents & purposes, the user makes the initial choice for this type of report by selecting a radio button, in this case that selection tells the fortran code that the user typed 'TS'. The fortran says, if 'TS' then show this grid (as mentioned above). From the grid, the user checks off fields (name, emp#, whatever). These choices are then passed back to the fortran as numbers. So, regardless of the questions, I just need the answers and if I can get it into the program, the fortran code will do what it needs to do. I really don't know how to explain this any better. I'm sorry - I'm not being intentionally obtuse.

Based on the information you've given me, I'd grep for ~GR~ in that text file, which would give you the lines

~GR~FIELD1GRID~1|2|3|5|6|7

...which probably isn't what you wanted.

If you want more, you'll have to explain what and why.

1 Like