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 6931487
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:35:02+00:00 2026-05-27T11:35:02+00:00

Hi I am trying to create a bash program to call a program and

  • 0

Hi I am trying to create a bash program to call a program and input menu picks into it.

For example my program runs

Hello world:
1) Item 1
2) Item 2
Enter : 2

Item 2 Menu
1) sub Item A
2) sub item B
enter: 1

I tried doing $ 2|1|./program and $./program|2|1

But it either fails or it just loops forever and doesn’t get to the second menu.

Is it possible to do this?

  • 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-27T11:35:03+00:00Added an answer on May 27, 2026 at 11:35 am

    Presuming a program that works essentially like this one:

    pmenu () {
        printf '%s) %s\n' "$1" "$2"
    }
    
    m1 () {
        pmenu 1 'Item 1'
        pmenu 2 'Item 2'
    }
    m2 () {
        pmenu 1 'sub Item A'
        pmenu 2 'sub Item B'
    }
    
    printf 'Hello, World:\n'
    
    m1
    read -p "enter: " m
    
    case "$m" in
        1 ) m2 ;;
        2 ) m2 ;;
    esac
    
    read -p "enter: " m
    
    echo "You chose: $m"
    

    Then you can just say

    printf '2\n1\n' | program
    

    For anything less straightforward you may need to learn expect, which is designed for this sort of thing.

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

Sidebar

Related Questions

I'm trying to create a simple BaSH-like grammar on ANTLRv3 but haven't been able
I'm trying to learn bash string handling. How do I create a bash script
I'm trying to run a program with a specific standard input. I succeed by
I'm trying to use process substitution for an input file to a program, and
I'm trying to create a FUNCTION in my Postgres database from a Bash script.
I am trying to create a BASH script what would extract the data from
I am trying to create a helpful bash alias/function. I can't seem to get
I'm trying to create a Bash script that will extract the last parameter given
I'm trying to create a short bash script someone could run in cygwin to
I am trying create a WCF service that leverages the WPF MediaPlayer on the

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.