I am running the following system command:

df -h | grep /db2/$DB2DBDFT/sapdata

in my script and assigning it to a variable which I then later print to a file and the file is then put in an email.

When I run the command at the prompt I get this:

df -h | grep /db2/$DB2DBDFT/sapdata 30G 26G 2.1G 93% /db2/BXP/sapdata1 30G 11G 18G 37% /db2/BXP/sapdata2 30G 23G 5.9G 80% /db2/BXP/sapdata3 30G 6.0G 23G 22% /db2/BXP/sapdata4 2.0G 36M 1.9G 2% /db2/BXP/sapdatat 2.0G 36M 1.9G 2% /db2/BXP/sapdatat2

When I run the script I get this error:

sh: line 82: printf: `/': invalid format character

The line number is wrong for one thing but that is besides the point. Here is the code:

print OUT "Current File System Usage:\n"; print OUT "Filesystem Size Used Avail Use Mounted on\n"; $rc = `df -h | grep /db2/$DB2DBDFT/sapdata`; print OUT "$rc\n";

I think it has to do with the / in the "filesystem name" column or the "Mounted on" column. The weird thing is that I don't have this problem on Unix.

I appreciate any suggestions on how to handle this.


In reply to print question by bp4a

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.