×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Buffing on filehandles

Buffing on filehandles

Buffing on filehandles

(OP)
I have a script which passes a line of formatted data in to an application.

I open the connection to the application thus

open (probe,"| nohup nco_p_generic");
        || die "Cant open probe";

the application can take data on the command line using the format
tokenname "value" tokenname "value" etc as long as the line is terminated with
\n\n the line is passed to the application.

I have a test line in the script which prints out using this format but prints to
STDOUT thus...

print STDOUT "tokenname \"value\" tokenname \"value\""

This works fine and lines are printed as they are recieved (The source of the data is a socket server and lines of data are constanlty flowing from a source client)

When I use the line

print probe "tokenname \"value\" tokenname \"value\""

There appears to be some delay or buffering. The whole thing works but I have to recieve multiple lines or wait 2 minutes not sure which is relevant
before the output lines are sent to the applications handle (probe).

Is there some difference between printing to STDOUT and pipes to applications in the way I have done it.

Thanks in advance for any suggestions

Frustrated Non-programmer but trying !!!

Steve Harvey

RE: Buffing on filehandles

I think what you are looking for is the output auto_buffer special var,  '$|', without the quotes.  Try setting $| to 1 which forces a flush of the buffer after every write or print.

$| = 1;

# do what you need and then set it back

$| = 0;

'hope this helps




keep the rudder amid ship and beware the odd typo

RE: Buffing on filehandles

Hmmm.....

two things:

1) I think you need to select() the filehandle befoew you set $|

select (probe); $|=1; select STDOUT


2) Secind thing is that might not work anyway -- and not through any fault of your own. The process you run on the end of the pipe might very well *not* pay you the same courtesy --- it might leave its output buffered..... So you would never know when you're going to get anything from it...

Mike
michael.j.lacey@ntlworld.com
Cargill's Corporate Web Site
Making mistakes, so you don't have to. <grin>

RE: Buffing on filehandles

(OP)
Thanks for your responses. The combined solutions worked a treat !
No more "Buffing for me this week !!!"

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close