How do I pass interactive commands in this case?

Discussion in 'Perl Misc' started by grocery_stocker, Dec 4, 2006.

  1. I have a program that access's a bbs. When I do the following:
    #!/usr/bin/perl -w
    my $kidpid;
    if (!defined($kidpid = fork())) {
    die "cannot fork: $!";
    } elsif ($kidpid == 0) {

    exec("bbs");
    die "can't exec date: $!";

    } else {

    waitpid($kidpid, 0);


    }

    I get
    23 newresponse items and 2 brandnew items
    First item 1, last 34

    Ok:


    The problem is that I want to pass the bbs 'browse' command at the
    "Ok:"
    prompt. Ie when I run the perl script, I want it to go like:

    23 newresponse items and 2 brandnew items
    First item 1, last 34

    Ok:browse

    Ideas?
     
    grocery_stocker, Dec 4, 2006
    #1
    1. Advertising

  2. A. Sinan Unur wrote:
    > "grocery_stocker" <> wrote in
    > news::
    >
    > > I have a program that access's a bbs. When I do the following:
    > > #!/usr/bin/perl -w
    > > my $kidpid;
    > > if (!defined($kidpid = fork())) {
    > > die "cannot fork: $!";
    > > } elsif ($kidpid == 0) {
    > >
    > > exec("bbs");
    > > die "can't exec date: $!";

    >
    > The fork+exec means that this process has now been replaced with the bbs
    > process. Interacting with that process is now no different than
    > interacting with any other external process.
    >
    > Have you looked into Expect.pm?
    >


    I've used expect once. It was sort of fuzzy the first time I used it.
    It was the same sort of fuzziness
    that I had when I first dealt with pointers in C..

    > >
    > > } else {
    > >
    > > waitpid($kidpid, 0);
    > >
    > >
    > > }

    >
    >
    > ...
    >
    > >
    > > The problem is that I want to pass the bbs 'browse' command at the
    > > "Ok:"prompt. Ie when I run the perl script, I want it to go like:
    > >
    > > 23 newresponse items and 2 brandnew items
    > > First item 1, last 34
    > >
    > > Ok:browse

    >
    > http://search.cpan.org/~rgiersig/Expect-1.20/
    >
    > Does the bbs program read its input from STDIN?
    >

    I'm not that sure if the bbs reads from STDIN. Is there any way to find
    out?

    > Do you need to read the responses from bbs?
    >


    Yes. I've also read the man pages for the bbs seeing if there was some
    way I could perhaps
    pass the browse option at the command line vs typing bbs and then
    typing browse at the
    "OK" prompt. There is no such option. All the command line options to
    the bbs are used to
    control how text gets inputed when you read or write a response to a
    thread.

    > Look also at "Bi-directional Communication with Another Process" in
    > perldoc perlipc
    >
    >
    > Sinan
    > --
    > A. Sinan Unur <>
    > (remove .invalid and reverse each component for email address)
    >
    > comp.lang.perl.misc guidelines on the WWW:
    > http://augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
     
    grocery_stocker, Dec 5, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. WJ
    Replies:
    2
    Views:
    544
  2. Ferruccio Vitale

    Interactive Commands

    Ferruccio Vitale, Mar 24, 2005, in forum: Java
    Replies:
    4
    Views:
    1,358
    Joona I Palaste
    Mar 25, 2005
  3. nanda
    Replies:
    0
    Views:
    453
    nanda
    Jul 18, 2006
  4. Ben Pfaff

    Re: man pages for C commands (GCC commands)

    Ben Pfaff, Jun 24, 2003, in forum: C Programming
    Replies:
    4
    Views:
    4,012
    Thomas Stegen
    Jun 28, 2003
  5. João Santos

    Interactive Commands

    João Santos, Aug 22, 2009, in forum: Ruby
    Replies:
    3
    Views:
    110
    Robert Klemme
    Aug 24, 2009
Loading...

Share This Page