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

Want to output a null character/byte 1

Status
Not open for further replies.

dickiebird

Programmer
Feb 14, 2002
758
GB
Hi
To satisfy our printer line-up criteria, all output for printing has a check on the first byte of output. If the byte is null, no line-up is required. Most programs are legacy DG-basic - don't ask how DG-basic does it - but it does!)
I'm using IBM RS2000 - AIX 4.2
I've written an awk script to output from comma-delimited files. What I cannot do is create a null byte as the first character. I've tried :-
printf("\0")
and
printf("%c",0)
and
printf("%d",\000)
and
printf(0)
and
printf("%x",\000)
and many other combinations.
Anyone any ideas, please ?
Kind regards
Dickie Bird
 

Hi dickiebird!

You can try this:

Code:
printf "%s", "\x00"

Warning: POSIX does not allow "\x" escapes.

Bye!

KP.
 
Then I must have POSIX compliance !
Result was "x00"
Thanks for the prompt reply, though !
Anybody else any ideas ????
 
Still no joy - this is what I'm trying :-
printf("%c\n", sprintf("%c", 0)) > PFILE
printf("JPY PAID T/C DETAILS OVER 5 YEARS AFTER SALE As At %s %s %s \n\n",gD,gM,gY) >> PFILE
(where PFILE is a -v variable passed to the script.
I get the heading OK, but the null still doesn't appear.
Any more thoughts ?? :cool:
 

Maybe is octal value acceptable:

Code:
printf "%s", "\000"

Bye!

KP.
 
Still no success - I'm going on holiday to France in a few hours - so I'll sleep on it for a week
Hvala vam
Dovid-enja
Dickie Bird
 
Hi,

I think that awh uses the null character as end of string mark (like in c).

You can write a null char in a file with the echo command :
echo "\000\c" > file

In your awk program, execute the "echo" command with "system" :

system("echo \"\\000\\c\" >" PFILE);
printf("JPY PAID ... As At %s %s %s \n\n",gD,gM,gY) >> PFILE;
Jean Pierre.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top