RE: /usr/bin/printf: %,: invalid directive
| Newsgroups | gmane.network.netsaint.user,gmane.spam.detected |
|---|---|
| Message-ID | <H000355e1c907485.1031142320.kcopmp01@MHS> |
BDY.RTF
(text/plain, 4 KB)
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