Piped open not real-time - How would one handle live data?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Piped open not real-time - How would one handle live data?
# 1  
Old 08-22-2007
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
# 2  
Old 08-22-2007
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?
# 3  
Old 08-23-2007
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
Login or Register to Ask a Question

Previous Thread | Next Thread

4 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Archiving or removing few data from log file in real time

Hi, I have a log file that gets updated every second. Currently the size has grown to 20+ GB. I need to have a command/script, that will try to get the actual size of the file and will remove 50% of the data that are in the log file. I don't mind removing the data as the size has grown to huge... (8 Replies)
Discussion started by: Souvik Patra
8 Replies

2. Shell Programming and Scripting

Converting real time to epoch time

# date +%s -d "Mon Feb 11 02:26:04" 1360567564 # perl -e 'print scalar localtime(1360567564), "\n";' Mon Feb 11 02:26:04 2013 the epoch conversion is working fine. but one of my application needs 13 digit epoch time as input 1359453135154 rather than 10 digit epoch time 1360567564... (3 Replies)
Discussion started by: vivek d r
3 Replies

3. Shell Programming and Scripting

Shell script to convert epoch time to real time

Dear experts, I have an epoch time input file such as : - 1302451209564 1302483698948 1302485231072 1302490805383 1302519244700 1302492787481 1302505299145 1302506557022 1302532112140 1302501033105 1302511536485 1302512669550 I need the epoch time above to be converted into real... (4 Replies)
Discussion started by: aismann
4 Replies

4. UNIX for Dummies Questions & Answers

Live/real-time text-file updates in terminal

I want to have a terminal open and have something like a "repeating cat" command running in it for a certain text file (in particular /var/log/system.log). So my terminal will scan or cat the text file every so often or whenever the text file system.log gets written to by the system, it will... (1 Reply)
Discussion started by: guitarscn
1 Replies
Login or Register to Ask a Question