LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
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 12-14-2010, 12:28 AM   #1
hattori.hanzo
Member
 
Registered: Aug 2006
Posts: 167

Rep: Reputation: 15
perl script output cannot pipe to file


I have a strange problem. My perl script produces the output when I run from the command line but when I pipe it to a file, it just hangs. ie. no output to the file at all.

Additional info:
There is one subroutine which does an ldap lookup, then passes the result via a 'return', then I 'print' the variable. This is all done in a while loop processing a list from a file.

Any pointers?

Thanks & Regards,

Last edited by hattori.hanzo; 12-14-2010 at 12:31 AM.
 
Old 12-14-2010, 01:51 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374
Hi,

Without the actual code it is a bit hard to guess what could be wrong.

One thing that does come to mind: Could it be that you are encountering perl's buffered output? Have a look here: Suffering from Buffering?

Hope this helps.
 
1 members found this post helpful.
Old 12-14-2010, 06:46 PM   #3
hattori.hanzo
Member
 
Registered: Aug 2006
Posts: 167

Original Poster
Rep: Reputation: 15
Thanks Druuna,

Thats a real interesting article about buffering in perl.

I ended up using the
Code:
$|++;
statement right after I open the file. I thought it was was the easiest to implement after also reading this.

Thanks & Regards
 
Old 12-15-2010, 02:26 AM   #4
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374
You're welcome
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
perl script output can't be redirected to a file nasridine Programming 7 02-19-2010 12:13 AM
Directing Script output to Memory but without using a pipe | telecom_is_me Programming 4 06-29-2008 12:17 AM
how to pass pipe output to file command nickleus Linux - General 6 06-19-2008 06:18 AM
How can I pipe output of a command into arguments of a script HGeneAnthony Linux - General 3 12-26-2007 06:24 AM
pipe xine output to file sohmc Linux - Software 0 01-01-2005 10:03 PM


All times are GMT -5. The time now is 08:52 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration