Loading ...
Sorry, an error occurred while loading the content.

Process communication via named pipes ...

Expand Messages
  • Stefan Jahnke
    Hi, I m trying to build a small Tk-GUI to remote-control Oracle s SQL*PLUS. The idea is to have open one pipe as a filehandle in order to write to a named
    Message 1 of 2 , Mar 4, 2001
    • 0 Attachment
      Hi,

      I'm trying to build a small Tk-GUI to "remote-control" Oracle's
      SQL*PLUS.
      The idea is to have open one pipe as a filehandle in order to write to a
      named pipe. The named pipe already exists (created with mkfifo). Then,
      SQL*PLUS is started (as a pipe / filehandle, too) taking it's input from
      the above mentioned named pipe.
      Now, as to give it a first try, I'm writing lines into SQLIN (the pipe
      I'm writing to). After having my lines written, I'm trying to read
      SQL*PLUS's output from the input pipe.
      At this moment, the script hangs (stepping through it with perl -d)
      after the line "while (<SQLOUT>) {".
      My question: How can I read line by line from the still open pipe ?
      It doesn't matter wether I'm using $ or @ to read, it always hangs :(.
      Any ideas ?

      Here's the script:

      #!/opt/perl5.00503/bin/perl -w

      open (SQLIN, "| cat > /home/myhome/pipe1");
      open (SQLOUT, 'sqlplus < /home/myhome/pipe1 |');

      while (<STDIN>) {
      $line = $_;
      print SQLIN $line;
      }

      while (<SQLOUT>) {
      $line = <SQLOUT>;
      print $line;
      }

      close SQLIN;
      close SQLOUT;

      --
      Regards,
      Stefan Jahnke
      BOV Software AG
    • tim dugan
      Good luck getting a response, Stefan...if you get any ideas back outside of the perl group, could you please share them? I ve been working on a similar
      Message 2 of 2 , Mar 5, 2001
      • 0 Attachment
        Good luck getting a response, Stefan...if you get any
        ideas back outside of the perl group, could you please
        share them? I've been working on a similar problem
        with named pipes for a while, and I'm not getting much
        headway... I've asked about it a few times on this
        group, but have got no response.

        I'm curious about these two lines of your code...

        open (SQLIN, "| cat > /home/myhome/pipe1");
        open (SQLOUT, 'sqlplus < /home/myhome/pipe1 |');

        could you clarify what that means? I assume the SQLIN
        statement creates an intermediate process,
        "cat"...something I would like to avoid if possible.
        And the SQLOUT statement creates a separate output
        path from sqlplus to the perl program...not actually
        using the named pipe in this case.

        I tried putting all the communications in one handle

        open(PIPE, "+</path/pipe");

        behind the named pipe is a continuously running
        process that creates the named pipe and acts as a
        read/write server on the backside. my perl program is
        a client that communicates with the server by reading
        and writing to the pipe.

        I can get this same concept to work with
        sockets...but, so far, not with named pipes...

        Any comments/suggestions welcome...
        -tim dugan
        mailto:timhoustontx@...

        --- perl-beginner@yahoogroups.com wrote:
        Message: 9
        Date: Mon, 05 Mar 2001 08:56:04 +0100
        From: Stefan Jahnke <stefan.jahnke@...>
        Subject: Process communication via named pipes ...

        Hi,

        I'm trying to build a small Tk-GUI to "remote-control"
        Oracle's
        SQL*PLUS.
        The idea is to have open one pipe as a filehandle in
        order to write to
        a
        named pipe. The named pipe already exists (created
        with mkfifo). Then,
        SQL*PLUS is started (as a pipe / filehandle, too)
        taking it's input
        from
        the above mentioned named pipe.
        Now, as to give it a first try, I'm writing lines into
        SQLIN (the pipe
        I'm writing to). After having my lines written, I'm
        trying to read
        SQL*PLUS's output from the input pipe.
        At this moment, the script hangs (stepping through it
        with perl -d)
        after the line "while (<SQLOUT>) {".
        My question: How can I read line by line from the
        still open pipe ?
        It doesn't matter wether I'm using $ or @ to read, it
        always hangs :(.
        Any ideas ?

        Here's the script:

        #!/opt/perl5.00503/bin/perl -w

        open (SQLIN, "| cat > /home/myhome/pipe1");
        open (SQLOUT, 'sqlplus < /home/myhome/pipe1 |');

        while (<STDIN>) {
        $line = $_;
        print SQLIN $line;
        }

        while (<SQLOUT>) {
        $line = <SQLOUT>;
        print $line;
        }

        close SQLIN;
        close SQLOUT;

        --
        Regards,
        Stefan Jahnke
        BOV Software AG


        ___________________________



        __________________________________________________
        Do You Yahoo!?
        Get email at your own domain with Yahoo! Mail.
        http://personal.mail.yahoo.com/
      Your message has been successfully submitted and would be delivered to recipients shortly.