Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Windows NT/2K backup log examination on linux (bash)

Status
Not open for further replies.

evgeniosc

IS-IT--Management
Oct 5, 2002
75
CY
I would like to write a script on a linux machine (using bash) that examines various logs and sends an email to administrator if an error occurs.

These logs includes windows 2k backup logs. These backup logs are in unicode format and though you can view them in bash (e.g using cat or more) you can not grep on them. Also you can not edit them using vi.

Is there any way in linux to convert these files in normal text format?

In windows I accomplished that with the command:
type backup_unicode.log>backup.log. (It does not work on linux)
 
Can't you use grep -U to force grep to treat them as Unicode?
 
-U treats the file(s) as binary not as unicode (this is different)
 
Converting your search terms to unicode and grep -U for that might work.
 
I tried to input the search terms as shown in vi but it does not work.

How do you suggest to convert the search terms in unicode?
 
Use a more advanced environment and interpreter than bash.
Try perl or tcl. Tcl is easier to code in IMHO and I'd
be willing to give you a start if you want to go that route.

Code:
proc unencodeutf {str} {return [encoding convertto $str]}
puts -nonewline stdout "Enter filename for read decoding: "
flush stdout
set filename [gets stdin]
if {![catch {set fd [open $filename r]} erropen]} {
     while {[gets $fd line] > -1} {puts "[unencodeutf $line]"}
     close $fd
} else {
     puts "ERROR: Opening file = $erropen"
     exit
}


 
I tried your script but the output is the same as the input.

Is there anything i should change in your script? (e.g the output encoding?)
 
Are you trying to decode or reformat .evt files?
As it is the encoding issue sounds a little weird to me
after some thought. The unicode to system encoding
should be seamless and should not require scripting if
the data isn't obfuscated. .Evt files are formatted
proprietarily, are binary files(that's why vi won't edit
them), and are best dealt with by using the windows
event viewer exportation in .txt (save as feature).

HTH





 
I am referring to backup log files and not .evt files.
The backup log files are readable text files in windows. In linux these file can be shown on the console but in vi are not shown correctly. Also more important is that you can not grep in these files.

An example of this file is:

Windows
-------
Operation: Backup


Linux (using vi)
----------------
^@O^@p^@e^@r^@a^@t^@i^@o^@n^@:^@ ^@B^@a^@c^@k^@u^@p^@^M^@

As it can be seen before every character there is a '^@'. Also in the start of file there is 'ÿþ'.

Anyway i developped a program in java the removes the unneeded characters and now the file is ok
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top