Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6187827
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T02:07:30+00:00 2026-05-24T02:07:30+00:00

I have a little program, let’s call it program by simplicity which has normal

  • 0

I have a little program, let’s call it “program” by simplicity which has “normal” behaviour. It takes information from the stdin (normally typed in by the user in the keyboard) and prints out via stdout/stderr. I want to automate a process and therefore redirect stdout/stderr into “my little bash script” (which could also be another program in C/C++). It takes it as it’s standard input and filters it. This means leaving out unimportant information.. and adding further information generated by the bash script itself. The output is shown on the sreen (printed out by the echo command).

This is working so far:

program --verbose 2>&1 | ./mylittlebashscript.sh

Scheme:

 stdin     +---------------+              +---------------+
 --------->|               |--stdout--+-->|      my       |-->screen
           |    program    |          |   |    little     |
           |               |--stderr--|   |  bash script  |
           +---------------+              +---------------+

Now I want to go one step further:
The program expects input from the user which I want to give automatically by my little bash script. For example it prompts the user to enter the path to a specific file. The path is known by my little bash script and the bash script knows when the program is waiting for input (as the last line being printed out contains something which is “greped”). How can I pipe back some information out of my bash script? I do not want to pipe back all the stdout because several information only needs to be displayed on the screen and the program would not like this output.

New scheme:

 (stdin?)  +---------------+              +---------------+   (stdout?)
 -------+->|               |--stdout--+-->|      my       |-->screen
        |  |    program    |          |   |    little     |
        |  |               |--stderr--+   |  bash script  |----+(maybe
        |  +---------------+              +---------------+    | stderr?)
        |                                                      |
        +------------------------------------------------------+

At the moment I am not very familiar with Linux yet. I guess there is a possibility working with cat, fifos, tee and pipes/redirections. Unfortunately I haven’t brought it to life so far.

I’d really be happy about a little example!
Thank you very much!

Cheers
Matthias

PS: I think this thread is related: how to redirect stdout of 2nd process back to stdin of 1st process?

Edit:
Ok, for fruther explanation I took my test files from my test machine:

I replaced “program” by another batch file called input.sh:

#!/bin/bash
echo "input.sh: give me input, waiting for input 1"
read x
echo $x
echo "input.sh: give me input, waiting for input 2"
read x
echo $x

And I got a second one (“mylittlebashscript.sh”), now called inter.sh to process:

#!/bin/bash
echo "inter.sh: start"
while read line ; do
  echo "inter.sh: line>$line"
  notfound=$(echo $line | grep "waiting")
  if [[ "$notfound" ]]; then
    echo "inter.sh: input sh seems to wait for input! putting something in the fifo"
    #echo "banana" > testfile
    #echo "I am the stderr" >&2
  fi

done
echo "inter.sh: end"
exit
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T02:07:31+00:00Added an answer on May 24, 2026 at 2:07 am

    An additional expect-like software tool would be empty!

    http://empty.sourceforge.net

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a little program that I want to make open automatically when my
I have a little c# console program that outputs some text using Console.WriteLine. I
I have been working on a childish little program: there are a bunch of
Let's say I have a simple config file that my c program needs to
I have created this little program to calculate pi using probability and ratios. In
I have been playing around with Template functions, and made a little logger program.
Just wondering what little scripts/programs people here have written that helps one with his
I have little knowledge of Flash but for a little Flash game I have
i have little problem with boost::asio library. My app receive and process data asynchronously,
I've been using python for years, but I have little experience with python web

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.