Find the answer to your Linux question:
Results 1 to 2 of 2
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    bash script and program interaction

    I want to write a bash script to run a bunch of data analysis programs on a large group of files. The programs that I call for each file are always the same ones and the parameters that I give to each program are the same regardless of which file I am working with. Unfortunately not all of the parameters can be added as command line arguments and the program prints messages and menus to the stdout of the terminal and the user replies via the keyboard and stdin to give the additional parameters. Is there a way to automate the calling of these programs in a linux shell, such as bash, where I can call a program and, while it is running (i.e. waitiing for stdin), feed it additional data (i.e. keystrokes) to satisfy its need for stdin?
    I have tried:
    $<program> -f <file_name) -o <output_name> -x <other parameters>
    echo "1"
    with the intention that <program> displays a menu with numerical choices 1-10 and waits for the user to make a choice via the keyboard before <program> finishes. This does not work though.

    thanks in advance,

  2. #2
    Linux Engineer drl's Avatar
    Join Date
    Apr 2006
    Saint Paul, MN, USA / CentOS, Debian, Slackware, {Free, Open, Net}BSD, Solaris
    Hi, journeyman01.

    Sounds like a here document will serve this purpose.

    For example, you know that cat reads from stdin. So if we write:

    cat <<EOF
    Hi, Mom!

    then "Hi, Mom!" will be sent to stdout.

    More information in the (longish) man page on bash ... cheers, drl
    Welcome - get the most out of the forum by reading forum basics and guidelines: click here.
    90% of questions can be answered by using man pages, Quick Search, Advanced Search, Google search, Wikipedia.
    We look forward to helping you with the challenge of the other 10%.
    ( Mn, 2.6.n, AMD-64 3000+, ASUS A8V Deluxe, 1 GB, SATA + IDE, Matrox G400 AGP )

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts