in reply to Re: trapping output of cu(1)?
in thread trapping output of cu(1)?

I suspected there would a simple way to redirect, and it appears that piping works:
#!/usr/bin/perl -w use strict; open(IN, 'cu -l cuaU0 -s 4800 |') or die 'unable to connect'; while (<IN>) { print; } close IN;
Is there anything glaringly wrong with this approach?

Thanks.

Replies are listed 'Best First'.
Re^3: trapping output of cu(1)?
by superfrink (Curate) on Oct 03, 2007 at 21:44 UTC
    When you open a process like that you can only read from it. That might be fine but if you need to read and write check into Expect like bruceb3 mentioned.

    Update: I don't see why you couldn't do some forking and create a child process with STDIN and STDOUT pointing to file handles the parent shares and then have the child exec the cu command. Try looking in perlfaq for "dup". How do I dup a filehandle in Perl