LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-20-2012, 03:16 PM   #1
EnderX
Member
 
Registered: Nov 2006
Posts: 66

Rep: Reputation: 15
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?
 
Old 06-21-2012, 07:04 AM   #2
kbp
Senior Member
 
Registered: Aug 2009
Posts: 3,790

Rep: Reputation: 653Reputation: 653Reputation: 653Reputation: 653Reputation: 653Reputation: 653
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell command output redirection - sudo doesn't block, can't supply passwords johndir Linux - General 6 11-22-2011 09:45 AM
question about input output redirection in c haydari Programming 3 04-16-2007 07:52 AM
Output and Error redirection in Shell script (MinGW) montylee Programming 6 09-08-2006 05:06 AM
shell script output redirection goral.j Programming 3 01-27-2005 05:34 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:30 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration