in reply to print question

Your error message says printf, but I don't see a printf in the 4 lines of perl code you posted.

Here is a wild guess. $DB2DBDFT is an environment variable. But, inside your perl code, $DB2DBDFT is just a plain variable which you have not defined. If it is an environment variable, then you should use:

$rc = `df -h | grep /db2/$ENV{DB2DBDFT}/sapdata`;
Also, use strict and warnings.

Replies are listed 'Best First'.
Re^2: print question
by bp4a (Initiate) on Jun 02, 2011 at 17:29 UTC
    unshift (@INC, "/db2/$DB2DBDFT/Scripts"); require 'variables.pl'; use Env;

    This is declared at the top of my script, I am telling it to use Environment variables.

    Works fine on Unix

    I think it has to do with the USE% column because in that column there is ##% then it lists the directory. So when it sees the % in the varible $rc followed by the / of the directory it says "Error" you are trying to do printf on a / which cannot be formatted by printf.

    Maybe I should be asking how to do a df command that drops the Use% column but gives me everything else?

      So when it sees the % in the varible $rc followed by the / of the directory it says "Error"

      Nothing you showed looks at what's in $rc except print, and print does not treat % specially. From what you told us, your diagnosis is incorrect.

      You could get that error if the contents of the file you write to is used as a printf format string by something else.

      Maybe I should be asking how to do a df command that drops the Use% column but gives me everything else?
      You could try parsing df output with the CPAN module: Filesys::Df

      Is it possible for you to reduce your code while still producing the same error? If you could post some code that anyone here could run, we might be able to help you debug it better. For example, does this simplified code still give you an error?

      use warnings; use strict; use autodie; open OUT, '> df.out'; my $rc = `df -h`; print OUT "$rc\n";