WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Binary Functions

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Using Binary Functions to Find Null (00) Characters

Keywords: 	 null character

Question:

I'm trying to have backup logs automatically sent via e-mail. What's happenning is that it's sending the first line of the file, and that's it.

With a hex editor, I found that immediately following the line it does send is:

   00 0D 0A 00 0D 0A
(space, CRLF, space, CRLF - I think)

By taking the spaces out, the whole file goes. Does winbatch think it's the EOF when it sees that pattern?

Answer:

That's
   00 0D 0A 00 0D 0A
(*NULL*, CRLF, *NULL*, CRLF - I think).

(Space is a 20 )

The *NULL* signifies end of data. Its considered binary information making it a non-text file and beyond the capability of the SMTP function.

Presumably you could "massage" the file prior to email to remove the null characters. How big is the file? For not-too-big files you could add this code....

*NOTE: TOTALLY UNDEBUGGED*

   fn="C:\temp\yourbackup.log"
   fs=FileSize(fn)
   bb=BinaryAlloc(fs)
   BinaryRead(bb,fn)
   fsX=fs-1
   for xx=0 to fsX
       byte=BinaryPeek(bb,xx)
       if byte==0 then BinaryPoke(bb,xx,32)
   next
   BinaryWrite(bb,fn)
   BinaryFree(bb)

;Now do the SMTP stuff 
Note 32 decimal == hex 20 == ascii space
Article ID:   W12741
Filename:   Using BinaryPeek to Find Null 00 Character.txt
File Created: 1999:04:15:16:49:18
Last Updated: 1999:04:15:16:49:18