APPX is the Premier Development and Runtime Environment for Business Application Software
(Answer) (Category) FAQ's - APPX Software, Inc. : (Category) Trash :
624 - File Analysis and Recovery
The appxutil.exe and recover.exe utilities, found in the /tools directory below the appx.exe engine, allow batch manipulation and recovery of AppxIO files in the Windows environment, from a DOS popup box. Similar utilities, called 'appx' and 'recover', perform the same functions in Unix.

Command Line Invocations: appxutil.exe or appx
Verifying and Analyzing a File
File Recovery: recover.exe or recover
What to do with a file that Fails Verification

Command Line Invocations: appxutil.exe or appx

'appxutil.exe' lets you perform switched invocations of APPX for Windows, without clearing the DOS box. From a Unix prompt, the command is simply 'appx'. Here's how you would use switches to verify and analyze APPX data files:

Issuing in the DOS box the command ... appxutil -u | more

 
Or in Unix, the command ... appx -u | more


... will result in the output ...

Usage:

        -k                          define a new keymap
-m=[user_id:]keymap_name override keymap ID
-d=<database_id> override startup database
-a=<application_id> override startup application
-t=<process_type> override startup process type
-p=<process_name> override startup process name
-i=<flat_file_name> convert a flat file into AppxIO
-e=<data_file_name> convert an AppxIO file into flatfile
-v=<data_file_name> verify the integrity of AppxIO file
-an=<data_file_name> analyze an AppxIO file
-l=<log file name> start a license server

Restrictions:
An application_id and process_type must always be included when specifying a process_name. If an application_id is included without specifying a process_type/name, the startup menu for the application is used.

If no application_id is specified, the startup application and menu for the database is used. If no database_id is specified, the startup database defined for the user within System Administration is used. If the startup database is also unspecified, the APPX main menu is used.

The valid process_types are Menu, Job, Input, Output, Update, Action, Inquiry, Query, Status, and Subroutine. Use underscores (_) in place of embedded spaces within parameters.

Substituting the "-k" through "-l=" switches will let you specify particular actions upon invoking the appx.exe engine.

(Consider the possibility of building your desired command line invocation strings in MS Word, Notepad or WordPad, then cutting and pasting them into your DOS box.)

For more information on appxutil.exe, see the APPXUTIL Overview.

Verifying and Analyzing a File


In Windows: %APPXPATH%\..\tools\appxutil.exe -v={filename}

 
In Unix: $APPXPATH/../tools/appx -v={filename}

... will manually verify an APPX datafile. This does the same thing as interactive "Verify Files Menu", "Verify Integrity" from the Database, Design File, and System Administration File Management menus, but from a command line.

If the invocation of this command results in no output, then the file passes verification. Any output from this command means that the file fails verification.

To analyze a damaged file ...

In Windows: %APPXPATH%\..\tools\appxutil.exe -an={filename}

 
In Unix: $APPXPATH/../tools/appx -an={filename}

... gives you a "BRF>" prompt for {filename}. The most useful command at this prompt is ...

VERIFY KEY #ALL

which performs counts the number of records in the .dat portion of the file verifying the .dat as it goes, and verifies all Keys in the .key portion of the file. Other useful commands are:

HELP - list all available commands.

DUMP HEADER - will give you info about the file, including the

                number of keys.

COUNT REC - will give a count of the number of records that

                {FILENAME.dat} believes it contains.

VERIFY KEY #0 - verifies the primary index, and gives # of records.

VERIFY KEY #1 - verifies the alt index #1, and gives # of records.

VERIFY KEY #2 - verifies the alt index #2, etcetera ...

QUIT - exit the "-an=" utility.

If the file doesn't pass #ALL verification, but does pass COUNT REC verification, then it means that the *.dat portion of the file is probably OK, but the *.key indices are probably damaged. In this case, rename or delete the *.key file, then run 3)CreateFiles. This will recreate your indices from scratch.

(For quite large files, it may be faster to use the 'recover.exe' procedure below, the 3)CreateFiles to recreate your keyfile, albeit at the cost of more designer time required to do this safely.)

If the file doesn't pass COUNT REC analysis, you have a seriously damaged *.dat file. Your best bet at this point is to use the "Recover.exe" procedure below, or if necessary restore from backup.

FREELIST damage

A type of file damage that VERIFY KEY #ALL does not tell you about is freelist damage. The freelist is the list of pointers in AppxIO files that point to deleted records. This list can get damaged. It could for example point to a live record, indicating erroneously that it is deleted.

Up through APPX version 4.0.a (and perhaps higher), the menu driven Verify Integrity utilities, the 'appx -v={filename}, and the 'appx -an={filename}', VERIFY KEY #ALL option don't detect such damaged freelist conditions.

To find a damaged freelist condition, you must use the APPX engine (the engine is all that's necessary) release 4.0.a or higher, then go into the BRF> command line from 'appx -an={filename}', then execute the command:

VERIFY FREELIST

If the freelist is damaged, this command will give you an error condition to that effect. To repair the damage, execute:

VERIFY KEY #ALL

If the file passes this verification, you may safely export and re-import the file, in order to initialize its freelist.

If the file doesn't pass #ALL verification, but does pass COUNT REC verification, then it means that the *.dat portion of the file is probably OK, but the *.key indices are probably damaged. In this case, rename or delete the *.key file, then run 3)CreateFiles. This will recreate your indices from scratch. It will then be safe to export and re-import the file.

(For quite large files, it may be faster to use the 'recover.exe' procedure below, then 3)CreateFiles to recreate your keyfile, albeit at the cost of more designer time required to do this safely.)

If the file doesn't pass COUNT REC analysis, you have a seriously damaged *.dat file. Your best bet at this point is to use the recover.exe procedure below, or if necessary restore from backup.

File Recovery: recover.exe or recover

Usage:
In Windows: %APPXPATH%\..\tools\recover.exe old.file new.file [deleted.record.file]

 
In Unix: $APPXPATH/../tools/recover old.file new.file [deleted.record.file]


This utility will read an APPX indexed data file (.dat) and copy the good/active records to the output file. Any corrupt data is hex-dumped to the screen. If you redirect standard output ( >bad.data ), you can collect any corrupted data into a file, for later examination.

Deleted Records are discarded, unless a third filename is given on the command line. In this case, the deleted records are copied to the given file. This file is a fixed-length consecutive file. To access it from within APPX, you must design transfer your data dictionary, remove the indices, and change the file type to consecutive. This is needed since the deleted records could contain duplicate key values.

Overhead blocks are also removed. These blocks are used to track deleted record space within the file for reuse. Since the new file has no deleted record space, it no longer needs these blocks.

This utility does not deal with duplicate primary or unique alternate indices.

*** IMPORTANT *** Any file you recover must have a new *.key file built. This is done by renaming or deleting the *.key file, then running 3)Create Files. The *.key file contains pointers to all of the data records in the *.dat file. By recovering the *.dat file, you invalidate the original *.key file.

Example:
The following command (in Windows) ...

recover.exe C:\APPX\DATA\DDD\PAT\Data\BB.dat C:\APPX\DATA\DDD\PAT\Data\BB.new

... will generate the following output and files ...

APPX Recover Utility: Input Filename = C:\32
\DATA\ttt\PAT\Data\bb.dat Output Filename = C:\32
\DATA\ttt\PAT\Data\bx.dat
File Header Information: File Organization = 3 ( Fixed Length Records ) Record Length = 19 UnixIO Version = 2 Freelist Starting Address = 0 End of File Address = 617 Recover Completion Information: Active Records Copied = 3 Deleted Records Removed = 0 Overhead Records Removed = 0 File Errors Found = 0 New Eof Seek Location = 617 Space Allocation Reduction = 0 bytes

*** You MUST create a new '.key' file that matches your new '.dat' file!

What to do with a file that Fails Verification?

If 13)Verify 1)Integrity results in a 'Failed' condition, perform the following procedure:

1) If you are running under Unix, su to the appx UserID.

2) Call up a MS-DOS Command box (or Unix Command prompt). Change directories:

cd {appx.exe.folder}\data\DDD\AAA\Data
... where ...
{appx.exe.folder} is the directory containing your 'appx.exe' engine, DDD is your Database ID (or for your Appl Design files, the Appl's 2-digit version#), and
AAA is your Application ID.

(If you are using FMS Groups, adjust this 'cd' accordingly.)

Example:

D:
cd \APPX\data\DBS\APL\Data

3) Type:
{appx.exe.folder}\tools\recover.exe FILE.dat FILE.new

... where FILE is the name of the file you are recovering.

4) From the Command prompt, perform:

ren FILE.dat FILE.dat.keep
ren FILE.key FILE.key.keep
ren FILE.new FILE.dat

 This moves the original FILE.* files out of the way (but keeps them around a while in case they're needed), then moves the recovered FILE.new into place as the new FILE.dat. 

5) Go back to Database Management (or Design File Management) for your application. Run 3)Create Files on FILE. This creates a new FILE.key to go along with your recovered FILE.dat.

  

To double-check, run 13)Verify Menu, 1)Integrity to confirm that the file is OK, and that the Active Records Copied above equals the number reported in the Verify Integrity utility.

[Append to This Answer]
2010-May-20 12:29am
Previous: (Answer) 603 - Automating Export/Import with Unix Crontabs
Next: (Answer) 627 - Moving APPX Files Between Platforms
This document is: http://board.appx.com/cgi-bin/fom.cgi?file=89
[Search] [Appearance]
This is a Faq-O-Matic 2.719.
Copyright 2003 by APPX Software, Inc. All rights reserved.