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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:28:42+00:00 2026-06-16T00:28:42+00:00

How would I run a command (this is a command line Java app), read

  • 0

How would I run a command (this is a command line Java app), read its output, and enter input into it, with a shell script. Is that possible? I heard about something called GNU Screen, but when I search with Google for it, it looks like something that won’t help me? I am very confused. So basically
I need to run a command, get its output, send send it input. Note: You need to input ‘exit’ to stop the command, so yes. I am confused here. Pointing me to a tutorial and explanation of GNU Screen or showing me something would be helpful.

  • 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-06-16T00:28:43+00:00Added an answer on June 16, 2026 at 12:28 am

    It sounds like what you are looking for is Expect, “[…] a tool for automating interactive applications such as telnet, ftp, passwd, fsck, rlogin, tip, etc.” using the Tcl scripting language.

    However, if no command you send to the program depends on previous output of the same program, Bash might work well enough by itself; just use temporary files and I/O redirection (as in Usman Saleem’s answer):

    • Save a list of commands into a first file; and
    • Redirect the program’s standard input to that file; and
    • Redirect the standard output to a second file.

    The read built-in command may prove useful for reading the generated output file.

    GNU screen is just a “terminal multiplexer” program that a) lets you have multiple terminal “windows” over a single modem or SSH connection and b) allows you to keep programs running even after you disconnect from a server. It is not the program you are looking for.

    One thing I would advise against is making your shell script both generate the program’s input and accept the program’s output in real time; data will get caught in the stdio output buffers, and deadlocks can happen. This is why Expect was created.

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

Sidebar

Related Questions

I usually run this program via a command line like so: java Program <TestClass.java
I read somewhere that you would never run syncdb on a database, post its
I am trying to run a Java program from my Perl script. I would
I normally use java.lang.ProcessBuilder and java.lang.Process to run external command line programs, and it
I have this error in eclipse helios: Exception occurred executing command line. Cannot run
With cron, if I wanted to run a command every 5 mins it would
I would like to create a ruby script that I can run mysql commands
I need to run mstest from the command line - where in the world
I have a script located at /tmp/My Batch Script Files/Processing How would I run
I would like to see what Eclipse executes on the command-line when launching my

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.