Find the answer to your Linux question:
Results 1 to 5 of 5
Script interfacing application I created a bash script to interface an application I wrote. The intention is this. The application does not have command line arguments per say but prompts ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Jun 2011
    Posts
    2

    Scripting/Application Interface


    Script interfacing application
    I created a bash script to interface an application I wrote.

    The intention is this. The application does not have command line arguments per say but prompts the user for information manually in the terminal. I want to write a script (for testing purposes) that has all the input for the program. Is there a way for the program to read in directly from the script that I created, the same script which calls/starts the application? In other words, the script starts the application but does not read in the rest of the "arguments", that are written into the script. Is there a way to automatically feed an application input from the terminal without doing so manually?

    Please let me know if I need to clarify myself, thanks!

  2. #2
    Linux Engineer hazel's Avatar
    Join Date
    May 2004
    Location
    Harrow, UK
    Posts
    1,225
    Yes, it's called a "here document".
    Code:
    << EOF
    input
    more input
    more input
    EOF
    rest of script
    The lines between "<<" and your designated end-of-file marker will be read as input.
    "I'm just a little old lady; don't try to dazzle me with jargon!"
    www.hrussman.entadsl.com

  3. #3
    Just Joined!
    Join Date
    Jun 2011
    Posts
    2
    Thanks for the help. Do you know the details of what happens after the second (closing) marker? I am just curious.

  4. #4
    Linux Engineer hazel's Avatar
    Join Date
    May 2004
    Location
    Harrow, UK
    Posts
    1,225
    Everything after the marker is treated as normal commands. But since the script hibernates once the program it launched is running (unless you launched it into the background using "&" ), those commands won't be executed until the child program terminates.
    "I'm just a little old lady; don't try to dazzle me with jargon!"
    www.hrussman.entadsl.com

  5. #5
    Linux Enthusiast
    Join Date
    Jan 2005
    Location
    Saint Paul, MN
    Posts
    651
    Take a look at the command "expect".

Posting Permissions

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