LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Question regarding perl output and shell redirection on SuSE 9.3 machine (https://www.linuxquestions.org/questions/programming-9/question-regarding-perl-output-and-shell-redirection-on-suse-9-3-machine-4175412534/)

EnderX 06-20-2012 03:16 PM

Question regarding perl output and shell redirection on SuSE 9.3 machine
 
I'm working on a program designed to read in a set of records from a file, and attempt to validate some of them against a database table. If it does not find a matching record, or if the record line has an ending character marking it as "Do not compare", it's supposed to print the line back out, verbatim, into a file which will be concatenated with another group from a different source for later loading into the database. (Using the perl print to filehandle method of 'print FH'.) There are two steps to the matching - verify that the record item exists, and verify that it has the right value in it.

I'm working, at the moment, with a test copy of the database that's a bit behind the production system, so I've got some records where I'm getting back empty string values on the second step - the item exists, but has nothing in it yet for the values I need to compare. I realize that this is a problem with my setup, and will be attempting to correct it. That's not the issue here.

In trying to filter out the 'known error' statements in the output, I've run into a rather bizarre set of circumstances I'm trying to figure out. I'm running Perl 5.8.6 on a SuSE 9.3 test machine which I believe is utilizing the bash shell, and things are going a bit wonky when I try to use shell redirection to store my output. (./Program > File1 2> File2 style redirection.)

Despite specifying a filename for the standard output redirect, and being in a directory where I have full write permissions, I'm never seeing it attempt to generate the output file I'm giving it. Additionally, if I give the standard error output a unique name, it comes out with no problem - but if I try using 2>&1 for it (alongside a unique > file1 name), I not only do not receive a file1, but the output on standard error appears to be getting piped into the intended output file my program is generating.

Does anyone have any suggestions as to what might be causing this, or recommendations for a better place to start looking? Or possibly a good way to rephrase this for Google, as I'm having trouble coming up with a search-ready way to describe this?

kbp 06-21-2012 07:04 AM

I'm not sure why it would be doing that but as a work-around you could try passing your output to a file within the script itself rather than using shell redirection.


All times are GMT -5. The time now is 11:02 PM.