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

  • Home
  • SEARCH
  • 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 7030807
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:43:13+00:00 2026-05-28T00:43:13+00:00

I would like to run a Dos program from a web server. The Dos

  • 0

I would like to run a Dos program from a web server. The Dos program has to be run interactively as the user interface is via a series of questions and answers. The answer to one question will determine the next question. I will have to use ajax on the web server, but I think I can do that.

I found one java program on Stackoverflow which seems to do something similar to what I want. However when I compile the program I get an error ie.

javac PipeRedirection.java 
PipeRedirection.java:43: package InputProcess does not exist
                    InputProcess.Gobbler outGobbler = new InputProcess.Gobbler(p.getInputStream());

The stack overflow question url was

How can I write large output to Process getOutputStream?

The Java file was

/* 
 ####### PipeRedirection.java 
*/

import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;

public class PipeRedirection {

public static void main(String[] args) throws FileNotFoundException {

    if(args.length < 2) {
            System.err.println("Need at least two arguments");
            System.exit(1);
    }

    try {
            String input = null;
            for(int i = 0; i < args.length; i++) {

                    String[] commandList = args[i].split(" ");

                    ProcessBuilder pb = new ProcessBuilder(commandList);
                    //pb.redirectErrorStream(true);
                    Process p = pb.start();

                    if(input != null) {
                            PrintWriter writer = new PrintWriter(new OutputStreamWriter(new BufferedOutputStream(p.getOutputStream())), true);
                            writer.println(input);
                            writer.flush();
                            writer.close();
                    }

                    InputProcess.Gobbler outGobbler = new InputProcess.Gobbler(p.getInputStream());
                    InputProcess.Gobbler errGobbler = new InputProcess.Gobbler(p.getErrorStream());
                    Thread outThread = new Thread(outGobbler);
                    Thread errThread = new Thread(errGobbler);
                    outThread.start();
                    errThread.start();

                    outThread.join();
                    errThread.join();

                    int exitVal = p.waitFor();
                    System.out.println("\n****************************");
                    System.out.println("Command: " + args[i]);
                    System.out.println("Exit Value = " + exitVal);
                    List<String> output = outGobbler.getOuput();
                    input = "";
                    for(String o: output) {
                            input += o;
                    }
            }
            System.out.println("Final Output:");
            System.out.println(input);

    } catch (IOException ioe) {
            // TODO Auto-generated catch block
            System.err.println(ioe.getLocalizedMessage());
            ioe.printStackTrace();
    } catch (InterruptedException ie) {
            // TODO Auto-generated catch block
            System.err.println(ie.getLocalizedMessage());
            ie.printStackTrace();
    }

}


public static class Gobbler implements Runnable {
    private BufferedReader reader;
    private List<String> output;

    public Gobbler(InputStream inputStream) {
            this.reader = new BufferedReader(new InputStreamReader(inputStream));
    }

    public void run() {
            String line;
            this.output = new ArrayList<String>();
            try {
                    while((line = this.reader.readLine()) != null) {
                            this.output.add(line + "\n");
                    }
                    this.reader.close();
            }
            catch (IOException e) {
                    // TODO
                    System.err.println("ERROR: " + e.getMessage());
            }
    }

    public List<String> getOuput() {
            return this.output;
    }
}
}

Does anyone know why I get the compile error? Can I substitute some other code for InputProcess?

Thanks for any help

Peter

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

    I think it’s pretty obvious that you’re missing parts to this code. A package named InputProcess which has a class called Gobbler was not included in the OP’s post. Probably because it was not relevant to their question.

    The error message essentially says that it can not find this package/code that it is looking for.

    What this class does exactly, only the OP can tell you. At its most basic, though, it appears to read from an InputStream and convert it to a List<String>. I would read up on Java IO and try to replicate similar functionality.

    Edit:

    Looks like the Gobbler class is indeed included in the example above. Remove the InputProcess package name from your code (or put the Gobbler class in an InputProcess package) and you should be good to go.

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

Sidebar

Related Questions

I would like to run a program from the bash shell. When the program
I would like to run a process from Python (2.4/2.5/2.6) using Popen , and
I would like to run something like: select * from table where field in
I would like to run PHPUnit tests on the development server as opposed to
I would like to run a sequence of R scripts from the bash command
I am writing a java program that runs under unix. It would like run
I would like to run a jar file right from the command line without
I would like to run a small Windows program on an Android slate. It
I would like to run Windows Server AppFabric Caching locally on a Windows 7
I would like to run my own internal PyPI server, for egg distribution within

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.