The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
An Introduction to Real-Time Data Integration iBot Oracle Updates (RSS) 0 04-06-2008 02:10 AM
Get real value from real-time systems iBot Complex Event Processing RSS News 0 01-13-2008 10:10 PM
Error Message: find: cannot open /: Stale NFS file handle ezsurf SUN Solaris 1 10-11-2007 05:04 PM
Open Source Is Dead, Long Live Open Patents? - InformationWeek iBot UNIX and Linux RSS News 0 07-13-2007 11:00 AM
EPOCH to real time? TheEngineer UNIX for Advanced & Expert Users 5 07-18-2006 05:30 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-22-2007
Registered User
 

Join Date: Jul 2007
Location: Cloud 9
Posts: 69
Piped open not real-time - How would one handle live data?

When I run "/etc/myApp" I am presented with continuous output, just about once per second.

However when I try to get the information in Perl via a piped open, it waits till the end to give me anything... my code:
Code:
open (OUTPUT,"/etc/myApp |");
    while (<OUTPUT>){
        print $_;
    }
close (OUTPUT);
Why is that, and how can I fix it so that I do get the progressive output?

I know that I can solve my particular problem by just pushing STDOUT to a temp file, and then parsing it... but I would prefer to learn how to handle "live" data
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 08-22-2007
Neo's Avatar
Neo Neo is offline
Administrator
 

Join Date: Sep 2000
Location: Asia Pacific
Posts: 4,301
I think perl is looking for a new line char before printing the line.

Maybe your output does not have a NL in the data?
Reply With Quote
  #3 (permalink)  
Old 08-23-2007
Registered User
 

Join Date: Jul 2007
Location: Cloud 9
Posts: 69
I just changed my code to this:
Code:
my @lines = split(/\n/, `/etc/myApp`);
print join("\n", @lines);
Thanks though... I just ran out of time trying to figure the other one out
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 01:32 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0