sandy105 has asked for the wisdom of the Perl Monks concerning the following question:

I have been having an anomaly of late . I have a script in which i use STDOUT to show logs and errors alike to the console and it runs perfectly locally

However when i deploy it and use a TWS scheduler to run it like below:

perl script.perl "arg" >> log.log 2>&1

It throws an error and stops the script. The error thrown is about not calling finish on a handle before disconnecting the DB

I am pretty sure i have done that and it never pops up when running normally (without piping to log ) . I have subdued the problem by calling finish explicitly before disconnecting DB. But i would love to know what's happening

Replies are listed 'Best First'.
Re: error while piping output
by bitingduck (Deacon) on Mar 10, 2015 at 08:39 UTC

    Are you testing it with the same data when you run normally vs piping vs the scheduler? The DBI docs say you should only see the error about not calling finish if you have data left unfetched from a statement handle when you go to disconnect. Can you post code and sample data (sanitized) that throws the error?

      Its a huge script with multiple DB calls and ftp'ing ~ 2k lines of code

      I assure you i am running the same input file Everytime , but this is really happening

      "if you have data left unfetched from a statement handle when you go to disconnect"

      what does it exactly mean ?

      i am really stumped on this one because its been tested for months and then finally error because of piping output & error to a logfile ..

Re: error while piping output
by Anonymous Monk on Mar 10, 2015 at 08:04 UTC

    However when i deploy it and use a scheduler to run it like below:

    What does that mean? What "scheduler"? How does "scheduler" execute that command?

Re: error while piping output
by sandy105 (Scribe) on Mar 10, 2015 at 08:11 UTC

    It's a TWS job- tivoli work scheduler & it runs it like:

     perl scriptname.perl arg >> log 2>&1

    UPDATE: 2&1 is piping stderror to stdout and when i run it locally it does NOT print/throw any error to console (db error), so i am pretty much amazed !! why it fails when run like that

      2&1 does not redirect. Did you mean 2>&1 (note the additional greather-than sign)?