kirov60 has asked for the wisdom of the Perl Monks concerning the following question:

I am writing a small script which is invoking a program which needs a input from the user. The input is standard value but I do not know, how to do that. ex: cat per-script date; getapdata; print "End of program" The getapdata program needs "1" as input. How to do that? I read about storing all inputs in file ex: apinput cat apinput 1 perl-script apinput But this does not work. I am new to perl and direction will be a big help regards kirov
  • Comment on How to give input to a program which is inside perl script

Replies are listed 'Best First'.
Re: How to give input to a program which is inside perl script
by NetWallah (Canon) on Jul 20, 2004 at 02:47 UTC
    Perhaps something like :
    system "echo 1 | getapdata";
    In case you need the output from getpdata, use backticks or the "qx" function.

    There are other, more complex options, including "open2".

        Earth first! (We'll rob the other planets later)

Re: How to give input to a program which is inside perl script
by naChoZ (Curate) on Jul 20, 2004 at 13:46 UTC

    Expect can do this easily.

    --
    People who want to share their religious views with you almost never want you to share yours with them.
    naChoZ