in reply to trapping output of cu(1)?

I have used Device::SerialPort with a USB device that was presented as a serial device in /dev .

Replies are listed 'Best First'.
Re^2: trapping output of cu(1)?
by Anonymous Monk on Oct 03, 2007 at 20:36 UTC
    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.

      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
Re^2: trapping output of cu(1)?
by Anonymous Monk on Oct 03, 2007 at 18:11 UTC

    I'm using one of the *BSD's. Do you have any knowledge if this module works there too?

    Is there not a way to redirect or dup the stdout filehandle used by another process?

    Thanks.