Re: /usr/bin/printf: %,: invalid directive

Kenneth.ray <[email protected]>
Newsgroups gmane.network.netsaint.user
Message-ID <[email protected]>
>

Dear sir,
Hi, I cannot provide you a reason why its happening  however I can provide you
with a solution
use the Echo command, I have yet to find a reason not to use Echo  versus
printf , this
stuff about the -e not being crossplatform is true. butif you are trying to
format a string
put it inside qoutes "  % this / that \ this still works - that too" if you
need tabs use the native
escape sequence \t all these normal escape characters are compatible with
echo. Without
getting into a discussion which is better and what you should use.
one thing to note if using the "\" in any of your output  if the \(char)
coresponds to a
valid escape sequence ie "\to_the_fight" will come out as
"    o_the_fight" as the \t is a valid escape sequence. but if you put "\
to_the_fight"
will come out as "\ to_the_fight" as will "\tto_the_fight"
I have tested these escape sequences with echo on solaris aix and redhat and
windows
nt/98/mileneum.  and all work perfectly withthe echo command.
a few i use, for those that dont know any, \n=next line \t=tab  and dont
forget the double qoutes
"\n" is not the same as \n


hope this helps
Kenneth Ray.






>
> Message: 5
> From: [email protected]
> Date: Wed, 4 Sep 2002 07:25:21 -0500
> Subject: RE: [netsaint] /usr/bin/printf: %,: invalid directive
> TO: [email protected], [email protected]
> CC: [email protected]
>
> I ran into a problem similar to this with disk space percentages.  If
> the return from your command has a '%' in it, printf doesn't handle it
> correctly unless it's a double '%%'.  I started using 'echo -e' instead
> of 'printf', however someone on this list suggested re-formating the
> string to printf:
>
> command[host-notify-by-email]=/usr/bin/printf "***** NetSaint
> *****\n\nNotification Type: %s\nHost:%s\nState: %s\nAddress: %s\nInfo:
> %s\n\nDate/Time: %s\n", $NOTIFICATIONTYPE$, $HOSTNAME$, $HOSTSTATE$,
> $HOSTADDRESS$, $OUTPUT$, $DATETIME$ | /bin/mail -s 'Host$HOSTSTATE$
> alert for $HOSTNAME$!' $CONTACTEMAIL$
>
> Stanley G. Martin
> Sprint - ISS Enterprise App/Decision Support Services
> [email protected]
>
>
> -----Original Message-----
> From: andres [mailto:[email protected]]
> Sent: Tuesday, September 03, 2002 8:46 PM
> To: Stanley.Hopcroft
> Cc: netsaint-users
> Subject: Re: [netsaint] /usr/bin/printf: %,: invalid directive
>
>
> Thanks ! Must be ping then, since it returns the % packet drop.
>
> So do you know if STDER can be piped out to /dev/null in the email
> command?
>
> I guess I can try it ;)
>
>
>
> ----- Original Message -----
> From: "Stanley Hopcroft" <[email protected]>
> To: "Andres L. Figari" <[email protected]>
> Cc: <[email protected]>
> Sent: Tuesday, September 03, 2002 4:30 PM
> Subject: Re: [netsaint] /usr/bin/printf: %,: invalid directive
>
>
> > Dear Sir,
> >
> > There is a bit of a gotcha with printf in that if it's arguments
> contain
> > the '%' character they may not be interpreted correctly.
> >
> > This shows the sort of trouble
> >
> > tsitc> printf '10%'
> > printf: illegal format character U
> >
> > Your choices are :-
> >
> >  . try and deeal with the plugin output containing '%' eg convert it
> to
> > %%
> >
> >  . replace echo and live with much poorer formatting (in general).
> >
> >
> > On Tue, Sep 03, 2002 at 03:54:50PM -0800, Andres L. Figari wrote:
> > > Hi,
> > >
> > > Dug throught the mailing list emails, I could swear I remeber this
> but
> can't
> > > find it :(
> > >
> > > I get a strange little error
> > >
> > > /usr/bin/printf: %,: invalid directive
> > >
> > > Netsaint works great, but at times, while in the machine and working
> with
> > > it, it prints oput on the screen  LOL
> > >
> > > Anyone know what this is about?
> > >
> > > Regards,
> > >
> > > Andres
> > >
> >
> > Another problem is that plugin putput cannot contain quote characters
> > "'" since they can't be escaped to /bin/sh.
> >
> > Yours sincerely.
> >
> > --
> >
> ------------------------------------------------------------------------
> > Stanley Hopcroft
> >
> ------------------------------------------------------------------------
> >
> > '...No man is an island, entire of itself; every man is a piece of the
> > continent, a part of the main. If a clod be washed away by the sea,
> > Europe is the less, as well as if a promontory were, as well as if a
> > manor of thy friend's or of thine own were. Any man's death diminishes
> > me, because I am involved in mankind; and therefore never send to know
> > for whom the bell tolls; it tolls for thee...'
> >
> > from Meditation 17, J Donne.
> >
> >
> > -------------------------------------------------------
> > This sf.net email is sponsored by: OSDN - Tired of that same old
> > cell phone?  Get a new here for FREE!
> > https://www.inphonic.com/r.asp?r=sourceforge1&refcode1=vs3390
> > _______________________________________________
> > Netsaint-users mailing list
> > [email protected]
> > https://lists.sourceforge.net/lists/listinfo/netsaint-users
> >
>
>
>
> -------------------------------------------------------
> This sf.net email is sponsored by: OSDN - Tired of that same old
> cell phone?  Get a new here for FREE!
> https://www.inphonic.com/r.asp?r=sourceforge1&refcode1=vs3390
> _______________________________________________
> Netsaint-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/netsaint-users
>
>
>




-------------------------------------------------------
This sf.net email is sponsored by: OSDN - Tired of that same old
cell phone?  Get a new here for FREE!
https://www.inphonic.com/r.asp?r=sourceforge1&refcode1=vs3390
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.