script to run the program

Discussion in 'Perl Misc' started by a, Sep 21, 2005.

  1. a

    a Guest

    I need to run a program that need input at run time.
    Is it possible to simulate this by perl?
    Thanx
     
    a, Sep 21, 2005
    #1
    1. Advertising

  2. a wrote:
    > I need to run a program that need input at run time.
    > Is it possible to simulate this by perl?
    > Thanx
    >
    >


    It depends.
    You can open a pipe to the program and send the input through the pipe
    (beware of buffering):
    open(DST, '|', $program);
    print DST "Input\n";

    Or look at Perl/Expect.
    --
    Josef Möllers (Pinguinpfleger bei FSC)
    If failure had no penalty success would not be a prize
    -- T. Pratchett
     
    Josef Moellers, Sep 21, 2005
    #2
    1. Advertising

  3. a

    Joe Smith Guest

    Josef Moellers wrote:
    > a wrote:
    >
    >> I need to run a program that need input at run time.
    >> Is it possible to simulate this by perl?

    >
    > It depends.
    > You can open a pipe to the program and send the input through the pipe
    > (beware of buffering):
    > open(DST, '|', $program);
    > print DST "Input\n";
    >
    > Or look at Perl/Expect.


    For interactive use (where a line of input depends on something that
    was output previously), a PTY-based solution (such as Expect.pm)
    is the way to go.
    http://search.cpan.org/author/DJERIUS/Expect-Simple-0.02/Simple.pm

    -Joe
     
    Joe Smith, Sep 26, 2005
    #3
    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. Tamer Higazi
    Replies:
    2
    Views:
    407
    Thomas M.
    Jul 22, 2003
  2. Shawn
    Replies:
    2
    Views:
    1,486
    Shawn
    Dec 6, 2006
  3. pradeep nair
    Replies:
    2
    Views:
    550
  4. Replies:
    9
    Views:
    982
    Paddy O'Loughlin
    Feb 27, 2009
  5. Yesterday Paid
    Replies:
    1
    Views:
    266
    Dave Angel
    Jun 21, 2012
Loading...

Share This Page