Re: Simple AWK question

2003-06-11 Thread Vidiot
>Your syntax error is that sprintf "prints" to a string buffer, not a file. 
>Now, p'rhaps he wants fprintf, 'e does, Precious

It is interesting how sprintf() >> "filename" has been working all the
years.  Probably for the wrong reason.

MB
-- 
e-mail: [EMAIL PROTECTED]/~\ The ASCII
 \ / Ribbon Campaign
[So it's true, scythe matters.  Willow  5/12/03]  X  Against
Visit - URL: http://vidiot.com/  / \ HTML Email


-- 
redhat-list mailing list
unsubscribe mailto:[EMAIL PROTECTED]
https://www.redhat.com/mailman/listinfo/redhat-list


Re: Simple AWK question

2003-06-11 Thread Vidiot
>I dont have my GAWK manual handy, but I think your problem may
>be that you are using SPRINTF which is a print to string function
>as in  str = sprintf() rather than something like  fprintf() or printf()

Not using gawk, using the original awk.  Don't know if the original awk even
supports fprintf() or printf().

>I would expect that the format overall would be
>
>   INPUT_SOURCE | awk -f awk-script_file > outputfile
>
>and awk-script_file
>   would contain your awk code
>   including something like
>
>   printf("\"%s\",\"%s\"\n", SiteVal, CustomerID);
>
>   or the %c format illustrated below...
>
>The syntax error may not be the "'s, but your use of sprintf and the more
>PERL Like
>>> "filename" . These constructs may have been added in GAWK, but they were
>not in
>the original AWK as far as I can remember.

The >> "filename" construct is definately in awk.  I see that printf is in the
awk man page.


In any event, I got it figured out.

MB
-- 
e-mail: [EMAIL PROTECTED]/~\ The ASCII
 \ / Ribbon Campaign
[So it's true, scythe matters.  Willow  5/12/03]  X  Against
Visit - URL: http://vidiot.com/  / \ HTML Email


-- 
redhat-list mailing list
unsubscribe mailto:[EMAIL PROTECTED]
https://www.redhat.com/mailman/listinfo/redhat-list


Re: Simple AWK question

2003-06-11 Thread mark
> From: Vidiot <[EMAIL PROTECTED]>
> Date: Wed, 11 Jun 2003 11:17:14 -0500 (CDT)
>
> In all my years of using awk, this is the first time I've ever had to
> output a " character to a file.  For example, I have the following:
>
> sprintf("%s,%s\n", SiteVal, CustomerID) >> "outputfile"
> I need the line in the output file to look like:
> "SiteVal","CustomerID"
>
How 'bout 
  outline = sprintf("\"%s\",\"%s\"\n", SiteVal, CustomerID) 
>
> I've tried "\"%s\",\"%s\"\n", but get a syntax error.  Instead of \",

Your syntax error is that sprintf "prints" to a string buffer, not a file. 
Now, p'rhaps he wants fprintf, 'e does, Precious

mark "will awk for $"

-- 
"The very powerful and the very stupid have one thing 
 in common.  Instead of altering their views to fit the 
 facts, they alter the facts to fit their views...which 
 can be very uncomfortable if you happen to 
 be one of the facts that needs altering." - Doctor Who


-- 
redhat-list mailing list
unsubscribe mailto:[EMAIL PROTECTED]
https://www.redhat.com/mailman/listinfo/redhat-list


RE: Simple AWK question

2003-06-11 Thread Kenneth Goodwin

I dont have my GAWK manual handy, but I think your problem may
be that you are using SPRINTF which is a print to string function
as in  str = sprintf() rather than something like  fprintf() or printf()

I would expect that the format overall would be

INPUT_SOURCE | awk -f awk-script_file > outputfile

and awk-script_file
would contain your awk code
including something like

printf("\"%s\",\"%s\"\n", SiteVal, CustomerID);

or the %c format illustrated below...

The syntax error may not be the "'s, but your use of sprintf and the more
PERL Like
>> "filename" . These constructs may have been added in GAWK, but they were
not in
the original AWK as far as I can remember.

Check the manual.

>  -Original Message-
>  From: [EMAIL PROTECTED]
>  [mailto:[EMAIL PROTECTED] Behalf Of Vidiot
>  Sent: Wednesday, June 11, 2003 1:06 PM
>  To: [EMAIL PROTECTED]
>  Subject: Re: Simple AWK question
>
>
>  >I suppose you could try
>  >sprintf("%c%s%c,%c%s%c\n", '"', SiteVal, '"', '"',
>  CustomerID, '"') >>
>  >"outputfile"
>
>  awk: syntax error near line 13
>  awk: illegal statement near line 13
>  awk: newline in string near line 13
>
>  It is definatly baffling.
>
>  MB
>  --
>  e-mail: [EMAIL PROTECTED]/~\
>  The ASCII
>   \ /
>  Ribbon Campaign
>  [So it's true, scythe matters.  Willow  5/12/03]  X  Against
>  Visit - URL: http://vidiot.com/  / \
>  HTML Email
>
>
>  --
>  redhat-list mailing list
>  unsubscribe mailto:[EMAIL PROTECTED]
>  https://www.redhat.com/mailman/listinfo/redhat-list
>


-- 
redhat-list mailing list
unsubscribe mailto:[EMAIL PROTECTED]
https://www.redhat.com/mailman/listinfo/redhat-list


Re: Simple AWK question

2003-06-11 Thread Anthony E. Greene
On 11-Jun-2003/11:17 -0500, Vidiot <[EMAIL PROTECTED]> wrote:
>In all my years of using awk, this is the first time I've ever had to output
>a " character to a file.  For example, I have the following:
>
>   sprintf("%s,%s\n", SiteVal, CustomerID) >> "outputfile"
>
>
>I need the line in the output file to look like:
>
>   "SiteVal","CustomerID"
>
>I've tried "\"%s\",\"%s\"\n", but get a syntax error.  Instead of \",
>I've tried \042 and still get a syntax error.  I've tried adding another %s and
>supplying \" and \042 as the string, only to get errors.
>
>How does one get sprintf in awk to oputput a " character?  The man page for
>sprintf doesn't say how to do it either.

For me, this would fall into the "find another way to do it" category. I'd
output the data tab-delimited and post-process it using perl, assuming I
already had the rest of the awk code written.  It would probably be faster
than spending a lot of time figuring this out.

Tony
-- 
Anthony E. Greene 
OpenPGP Key: 0x6C94239D/7B3D BD7D 7D91 1B44 BA26  C484 A42A 60DD 6C94 239D
AOL/Yahoo Chat: TonyG05  HomePage: 
Linux: the choice of a GNU Generation. 


-- 
redhat-list mailing list
unsubscribe mailto:[EMAIL PROTECTED]
https://www.redhat.com/mailman/listinfo/redhat-list


Re: Simple AWK question

2003-06-11 Thread johnw02
Try using sprintf("%c", 042 )  and whatever else you need to complete
this.

> In all my years of using awk, this is the first time I've ever had to
> output
> a " character to a file.  For example, I have the following:
>
>   sprintf("%s,%s\n", SiteVal, CustomerID) >> "outputfile"
>
>
> I need the line in the output file to look like:
>
>   "SiteVal","CustomerID"
>
> I've tried "\"%s\",\"%s\"\n", but get a syntax error.  Instead of \",
> I've tried \042 and still get a syntax error.  I've tried adding another
> %s and
> supplying \" and \042 as the string, only to get errors.
>
> How does one get sprintf in awk to oputput a " character?  The man page
> for
> sprintf doesn't say how to do it either.
>
> Thanks.
>
> MB
> --
> e-mail: [EMAIL PROTECTED]/~\ The ASCII
>  \ / Ribbon
> Campaign
> [So it's true, scythe matters.  Willow  5/12/03]  X  Against
> Visit - URL: http://vidiot.com/  / \ HTML Email
>
>
> --
> redhat-list mailing list
> unsubscribe mailto:[EMAIL PROTECTED]
> https://www.redhat.com/mailman/listinfo/redhat-list
>


-- 
redhat-list mailing list
unsubscribe mailto:[EMAIL PROTECTED]
https://www.redhat.com/mailman/listinfo/redhat-list


Re: Simple AWK question

2003-06-11 Thread Vidiot
>I suppose you could try
>   sprintf("%c%s%c,%c%s%c\n", '"', SiteVal, '"', '"', CustomerID, '"') >>
>"outputfile"

awk: syntax error near line 13
awk: illegal statement near line 13
awk: newline in string near line 13

It is definatly baffling.

MB
-- 
e-mail: [EMAIL PROTECTED]/~\ The ASCII
 \ / Ribbon Campaign
[So it's true, scythe matters.  Willow  5/12/03]  X  Against
Visit - URL: http://vidiot.com/  / \ HTML Email


-- 
redhat-list mailing list
unsubscribe mailto:[EMAIL PROTECTED]
https://www.redhat.com/mailman/listinfo/redhat-list


RE: Simple AWK question

2003-06-11 Thread Kenneth Goodwin
>
>  In all my years of using awk, this is the first time I've
>  ever had to output
>  a " character to a file.  For example, I have the following:
>
>   sprintf("%s,%s\n", SiteVal, CustomerID) >> "outputfile"

I suppose you could try
sprintf("%c%s%c,%c%s%c\n", '"', SiteVal, '"', '"', CustomerID, '"') >>
"outputfile"

A little hokey, but should work..


>
>
>  I need the line in the output file to look like:
>
>   "SiteVal","CustomerID"
>
>  I've tried "\"%s\",\"%s\"\n", but get a syntax error.  Instead of \",
>  I've tried \042 and still get a syntax error.  I've tried
>  adding another %s and
>  supplying \" and \042 as the string, only to get errors.
>
>  How does one get sprintf in awk to oputput a " character?
>  The man page for
>  sprintf doesn't say how to do it either.
>
>  Thanks.
>
>  MB
>  --
>  e-mail: [EMAIL PROTECTED]/~\
>  The ASCII
>   \ /
>  Ribbon Campaign
>  [So it's true, scythe matters.  Willow  5/12/03]  X  Against
>  Visit - URL: http://vidiot.com/  / \
>  HTML Email
>
>
>  --
>  redhat-list mailing list
>  unsubscribe mailto:[EMAIL PROTECTED]
>  https://www.redhat.com/mailman/listinfo/redhat-list
>


-- 
redhat-list mailing list
unsubscribe mailto:[EMAIL PROTECTED]
https://www.redhat.com/mailman/listinfo/redhat-list


Re: Simple AWK question

2003-06-11 Thread Edward Croft
Have you tried using three " in a row. For example,
"""SiteVal""","""CustomerID"""

On Wed, 2003-06-11 at 12:17, Vidiot wrote:
> In all my years of using awk, this is the first time I've ever had to output
> a " character to a file.  For example, I have the following:
> 
>   sprintf("%s,%s\n", SiteVal, CustomerID) >> "outputfile"
> 
> 
> I need the line in the output file to look like:
> 
>   "SiteVal","CustomerID"
> 
> I've tried "\"%s\",\"%s\"\n", but get a syntax error.  Instead of \",
> I've tried \042 and still get a syntax error.  I've tried adding another %s and
> supplying \" and \042 as the string, only to get errors.
> 
> How does one get sprintf in awk to oputput a " character?  The man page for
> sprintf doesn't say how to do it either.
> 
> Thanks.
> 
> MB
> -- 
> e-mail: [EMAIL PROTECTED]/~\ The ASCII
>  \ / Ribbon Campaign
> [So it's true, scythe matters.  Willow  5/12/03]  X  Against
> Visit - URL: http://vidiot.com/  / \ HTML Email
> 


-- 
redhat-list mailing list
unsubscribe mailto:[EMAIL PROTECTED]
https://www.redhat.com/mailman/listinfo/redhat-list