Btrieve file only shows partial data - pervasive

Almost ready to throw up the white flag but thought I'd throw it out there. I have an OLD program from 1994 that uses a btrieve dB and renders basic membership info for a gym. The btr file that holds the data will open in notepad and I can search and find all records although the formatting is nearly unreadable. When it opens in the program there is a huge chunk of records missing. It seems to stop on specific records up and down when scrolling.
I know almost nothing about btrieve as it predates my IT career by many years and I've honestly never seen it. Any suggestions on where I should troubleshoot or tools that may help would be much appreciated.

This sounds like the file may be corrupted although I would expect errors if it was corrupted. One way to rebuild the file is to use BUTIL (and a couple of OS commands).
The steps to rebuild are:
Make a backup of the original file to another directory.
Rename the original file. I like to use change the extension to .OLD.
Delete the original file. It will be recreated in the next step.
Issue the BUTIL -CLONE command (BUTIL -CLONE
Issue the BUTIL -COPY command (BUTIL -COPY
The rebuild is complete.
I've use the commands below in the past (changing 'filename' and the extensions to match my files).
copy filename.btr someother\location\filename.btr
ren filename.btr filename.old
del filename.btr
butil -clone filename.btr filename.old
butil -copy filename.old filename.btr

Related

Pervasive SQL(10.3) File size exceeding 2GB resulting in a .^01 file being created

We have a database with a data file exceeding 2Gb, this resulted in a .^01 file being generated with the same file name. We now have a .DAT file and a .^01 with the same name.
I have subsequently deleted the unnecessary data (old history, no longer required) and the .DAT file is now only 372MB, but the .^01 file remains.
I would like to clone the .DAT file and save the data and reload it into the cloned (blank file. I normally use Butil (Clone, Save and Load) but am unsure what I need to do with the .^01 file as the Butil -Save FileName.^01 FileName.seq returns an error as it does not recognise the ^:
BUTIL-14: The file that caused the error is FileName.01.
BUTIL-100: MicroKernel error = 12. The MicroKernel cannot find the specified file.
I would greatly appreciate some direction/input in this regard
Thank you and kind regards,
You don't need to do anything with the .^XX file(s). They are called Extended files and are automatically handled by the PSQL engine. A BUTIL -CLONE / -COPY will read all of the data (original file and extended file(s)) and copy it to the new file.
To rebuild it, you should do something like:
BUTIL -CLONE <NEWFILE.DAT> <OLDFILE.DAT>
BUTIL -COPY <OLDFILE.DAT> <NEWFILE.DAT>
Also, if the file grows above 2GB again, the Extended File (.^01) will come back.

Shake: automatically deleting file after failed command

Using Shake, to create an mp3 (this is just a learning example), I use lame, and then id3v2 to tag it.
If the lame succeeds, but the id3v2 fails, then I'm left with the mp3 file in place; but of course it is "wrong". I was looking for an option to automatically delete target files if a producing command errors, but I can't find anything. I can do this manually by checking the exit code and using removeFiles, or by building in a temporary directory and moving as the last step; but this seems like a common-enough requirement (make does this by default), so I wonder if there's a function or simple technique that I'm just not seeing.
The reason Make does this by default is that if Make has a partial incomplete file on disk, it considers the task to have run successfully and be up to date, which breaks everything. In contrast, Shake records that a task ran successfully in a separate file (.shake.database), so it knows that your mp3 file isn't complete, and will rebuild it next time.
While Shake doesn't need you to delete the file, you might still want to so as to avoid confusing users. You can do that with actionOnException, something like:
let generateMp3 = do cmd "lame" ... ; cmd "id3v2" ...
let deleteMp3 = removeFile "foo.mp3"
actionOnException generateMp3 deleteMp3

Batch file to save all opened files and then shutdown system

I did not find a solution online, so I will ask it here.
I would like to create a batch file that will save all openend work (for example: An opened and unsaved Word document). After it saves all opened work (with added an timestamp or a text with 'autosave'), it must shutdown.
The last part I can make myself (shutdown -t 0), but the first part is too difficult for me.
Do you have any solution?
Thank you for considering my question,
ButerBreaGrieneTsiis

Strange timestamp duplication when renaming and recreating a file

I'm trying to rename a log file named appname.log into the form appname_DDMMYY.log for archiving purposes and recreate an empty appname.log for further writing. When doing this in Windows 7 using C++ and either WinAPI or Qt calls (which may be the same internally) the newly created .log file strangely inherits the timestamps (last modified, created) from the renamed file.
This behaviour is also observable when renaming a file in Windows Explorer and creating a file with the same name quickly afterwards in the same directory. But it has to be done fast. After clicking on "new Text File" the timestamps are normal but after renaming they change to the timestamps the renamed file had or still has.
Is this some sort of Bug? How can I rename a file and recreate it shortly afterwards without getting the timestamps messed up?
This looks like it is by design, perhaps to try to preserve the time for "atomic saving." If an application does something like (save to temp, delete original, rename temp to original) to eliminate the risk of a mangled file, every time you saved a file the create time would increase. A file you have been editing for years would appear to have been created today. This kind of save pattern is very common.
https://msdn.microsoft.com/en-us/library/windows/desktop/ms724320(v=vs.85).aspx
If you rename or delete a file, then restore it shortly thereafter, Windows searches the cache for file information to restore. Cached information includes its short/long name pair and creation time.
Notice that modification time is not restored. So after saving the file appears to have been modified and the creation time is the same as before.
If you create "a-new" and rename it back to "a" you get the old creation time of "a". If you delete "a" and recreate "a" you get the old creation time of "a".
This behaviour is called "File Tunneling". File Tunneling is allow "...to enable compatibility with programs that rely on file systems being able to hold onto file meta-info for a short period of time". Basically backward compatibility for older Windows systems that use a "safe save" function that involved saving a copy of the new file to a temp file, deleting the original and then renaming the temp file to the original file.
Please see the following KB article: https://support.microsoft.com/en-us/kb/172190 (archive)
As a test example, create FileA, rename FileA to FileB, Create FileA again (within 15 seconds) and the creation date will be the same as FileB.
This behaviour can be disabled in the registry as per the KB article above. This behaviour is also quite annoying when "forensicating" Windows machines.
Regards
Adam B
Here's a simple python script that repro's the issue on my Windows7 64bit system:
import time
import os
def touch(path):
with open(path, 'ab'):
os.utime(path, None)
touch('a')
print " 'a' timestamp: ", os.stat('a').st_ctime
os.rename('a', 'a-old')
time.sleep(15)
touch('a')
print "new 'a' timestamp: ", os.stat('a').st_ctime
os.unlink('a')
os.unlink('a-old')
With the sleep time ~15 seconds I'll get the following output:
'a' timestamp: 1436901394.9
new 'a' timestamp: 1436901409.9
But with the sleep time <= ~10 seconds one gets this:
'a' timestamp: 1436901247.32
new 'a' timestamp: 1436901247.32
Both files... created 10 seconds apart have the time created-timestamp!

How do I view or rename a file with missing extension?

I have a strange file in my file system without the extension part. The filename is "15.". The weird thing is that it is not one of those without the dot part (like just "15"), but the one with the dot but no extension ("15.") -- it is literally an illegal filename in windows, and not sure how did it get created in the first place.
I know it is a text file and it is about 15KB in size; however, due to the weirdness in name, I can't open it with any application -- I've tried to open in notepad, wordpad, etc., have tried the 'type' command to spit it out on commans shell, tried to shell-open enclosing filename in quotes, and so on -- all methods result in a 'file not found' error except the notepad, which says '15.txt' is not found.
Due to the nature of the issue and the way search engines optimize the search, it is extemely hard to search for an answer in any of the search engines online. So, I just wanted to put this question out there and see if anybody had to deal with a similar issue and have found any way to rename the file or even to change the extension.
Filenames that are valid in NTFS but cannot be used from Windows can be created when accesing disks or shares from other operating systems like Linux.
If you don't have a Linux installation at hand, then get hold of a "live" CD, boot Linux, and change the filename.
That may sound like a hassle, but Windows-only solutions (moving stuff around, deleting the directory) are even worse.
Use REN: http://ss64.com/nt/ren.html
It is a command prompt command (run > cmd > cd wherever > ren 15. 15.txt )

Resources