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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Parsing output

Status
Not open for further replies.

mbach

Technical User
Dec 12, 2000
24
US
All,

The output below is from my backup error log on my master server (Solaris 8) running Netbackup 4.5
I am trying to use awk to strip out the failed files which could not be backed up. The failed files all start with a capital letter (for drive index) followed by a colon. The catch is that some file paths have spaces between the folder names and I think awk might have a problem with that.
Example: C:\Program Files\...\...
Is there an awk command or script which would get this info for me? I want to have the failed files all listed in another file for viewing.
Thanks!!!!!

===============================================
$server error messages for the past 24 hours
===============================================
TIME SERVER/CLIENT TEXT
04/30/2003 21:17:19 (Backup server) client from client x: WRN - OTM Error:0xe0001005 (WIN32 -536866811: Unknown
error)
04/30/2003 21:17:26 (Backup server) client from client x: WRN - OTM Error: will attempt to reenable OTM
04/30/2003 21:26:33 (Backup server) client from client x: ERR - OTM Error while reading file:
E:\e_new\urlcache\dir4\http!``04/30/2003 22:14:33 (Backup server)client backup of client x exited with status 1 (the requested
operation was partially successful)
 
Based on your example try something like:
{
if ($0 ~ /^[A-Z]:.*/) {
print "Failed at: ", $0 >> twofile
}
}

 
marsd,

Thanks but I do not get any output. Any suggestions?
Mike
 
Yeah, should've tested it, sorry.

Here's some code that id's the line and
removes the whitespace from the start tp
log more nicely.

Code:
         if ($0 ~ /^[\t ]/ && $0 ~ /[A-Z]:.*/) {
             x=1 
             while (var !~ /[A-Z]/) {
                    var = substr($0,x,1)
                    x++
              }
             $0 = substr($0,(x-1),(length($0) - x))
             print "Failed at: ", $0 >> outfile
         }
}

OP:
Failed at: E:\e_new\urlcache\dir4\http!``
 
marsd,
I keep getting syntax error near line 1.
How would the command look on one command line?
Thanks!!
Mike
 
awk ' {
if ($0 ~ /^[\t ]/ && $0 ~ /[A-Z]:.*/) {
x=1
while (var !~ /[A-Z]/) {
var = substr($0,x,1)
x++
}
$0 = substr($0,(x-1),(length($0) - x))
print "Failed at: ", $0 >> outfile
}
}' filename

make sure you use nawk/gawk and not solaris' old
awk: which is a fossil and should be discontinued
from what I've seen.
 
marsd,
I get no output from the command. This is the command i am using along with yours.....
bperror -problems|grep $server|(your command above).
There is no error but I know there should be a file for the server I am grepping.
Thanks for your help so far!!!!
Mike
 
So you are piping the results of some system utility
through a grep filter before filtering with awk?

I'm not surprised it doesn't work.
I copied the OP you posted originally to a file and then assumed that this is the method you were using.

Using a different method breaks this script which looks
for a specific pattern set.
If the output of your bperror -problems gives you output
like the original post's example then pipe it directly
to the script.
Otherwise, unless the logfile or process tapped by your
bperror utility is very different from the log example
you originally posted, just follow the model of my
previous post and forget about the bperror utility.

Also, FYI: Using awk one does not need to use grep
or other text filters..awk has equally powerful
regexp matching abilities to grep and these can be
programmed easily.
 
marsd,
After looking at my output on my master server, I realized
that the output I listed above was copied from our netbackup
web page error log. Here is output from the bperror -problems|grep server on the unix command line....

OTM Error: will attempt to reenable OTM
1053146843 1 4 8 nbm1 281555 281555 0 client x bpbrm from client x: WRN - OTM Error: will attempt to reenable OTM
1053146843 1 4 16 nb 281556 281555 0 client x bpbrm from client x: ERR - OTM Error while reading file: D:
1053146843 1 4 16 nb 281555 281555 0 client x bpbrm from client x: ERR - OTM Error while reading file: C:\WINNT
1053146843 1 4 16 nb 281560 281555 0 client x bpbrm could not write KEEPALIVE to COMM_SOCK
1053146843 1 4 16 nb 281560 281555 0 client x bpbrm from client x: ERR - OTM Error while reading file: F:\Mssql7\Backup\epimed200\epimed200_db_200305160200.BAK
1053146971 1 4 8 nb 281557 281555 0 client x bpbrm from client x: WRN - can't open file: E:\mssql7\Backup\eeimsc001\eeimsc001_db_200305162350.BAK (WIN32 32: The process cannot access the file because it is being used by another process. )
1053147390 1 4 16 nb 281555 281555 0 client x bpsched backup of client x exited with status 1 (the requested operation was partially successful)
1053147391 1 4 16 nb 281558 281555 0 client x bpbrm could not write KEEPALIVE to COMM_SOCK
1053147392 1 4 16 nb281558 281555 0 client x bpbrm could not send server status message
1053147392 1 4 8 nb 281558 281555 0 client x bpbrm Could not set linger value on socket. Errno = 22: Invalid argument
1053147412 1 4 16 nb 281556 281555 0 client x bpbrm could not send server status message

I need the file paths from this output and nothing more.
Thanks!!!!!
Mike
 
Something like this?
Code:
 {
        
       if  ($0 ~ /file/ && $0 ~ /[A-Z]:/) {
            match($0,/[A-Z]:.*/)
            line = substr($0, RSTART,RLENGTH)
            gsub(/[\ t].*$/,"",line)
            print line
         }
}

Of course, if you have spaces in your pathname
this will fail, but given the example you submitted
this should work.


 
marsd,
I still get errors when I try your command. I think I found
a way to get the file path including spaces. The command
is.....
awk ' {i=index ($0,"C:"); j=index ($0,"WIN32"); x=j-i-1;
if (i!=0) print substr ($0,i,x);}'
This keys on the string WIN32 and prints the file path including spaces. This was shown to me by someone at work.
One problem is that not all paths will start with C: . How
can I use a range of all capital letters followed by a colon
in the first index so that it will print all file paths that are listed?
Thanks,
Mike
 
Remark out the gsub() line.

When you say 'errors', what do you mean?
Like your awk doesn't have match() or
something?

I think that the problem is more easily resolved
using match(). In the data sample you provided
there is no really good way to just separate a
pathname with whitespace from anything following
the last path element, since the path is sometimes
a directory, and sometimes a filename.

My only theory on this is if a parenthesized error
message is usually the backup software's appended
string, a simple gsub(/\(.*\)/,"",line), should
work.

 
marsd,
I noticed that the failed files always follow the word "file:". The file path (with embedded spaces) ends when the string
"(WIN32" appears, or a series of numbers appears (as in a date or job id). Here is an example...
...can't open file: E:\graphics1\cat home\design (WIN32 32: The process cannot access the file ....
...can't open file: E:\graphics1\cat home\design 1053573994 4 3 ....
Can awk with sed be used to isolate the files in between the
strings mentioned above?
That should do it.
Thanks!!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top