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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T22:58:17+00:00 2026-05-31T22:58:17+00:00

I am using cygwin to get unix environment on windows. I have some shell

  • 0

I am using cygwin to get unix environment on windows.

I have some shell script that run on cygwin to perform syncing works and other things. I want to executes these script through java code.

Also during executing of scripts on cygwin , certain information is displayed on terminal by using simple echo command.. I want to show all that information in my application.

How can I 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-31T22:58:19+00:00Added an answer on May 31, 2026 at 10:58 pm

    Use the Runtime class to run Cygwin. This is very brittle, and dependent upon your setup, but on my machine I would do:

    Runtime r = Runtime.getRuntime();
    Process p = r.exec("C:\\dev\\cygwin\\bin\\mintty.exe --exec /cygpath/to/foo.sh");
    

    Then wait for the Process to complete, and get a handle to it’s InputStream objects to see what was sent to stdout and stderror.

    The first part of the command is to run cygwin, and the second is to execute some script, or command (using -e or --exec). I would test this command on the DOS prompt to see if it works first before cutting any code. Also, take a look at the options available by doing:

    C:\dev\cygwin\bin\mintty.exe --help
    

    Also from within the DOS prompt.

    EDIT: The following works for me to print version information

    
    public class RuntimeFun {
       public static void main(String[] args) throws Exception {
          Runtime r = Runtime.getRuntime();
          Process p = r.exec("C:\\dev\\cygwin\\bin\\mintty.exe --version");
          p.waitFor();
    
          BufferedReader buf = new BufferedReader(
                   new InputStreamReader(
                            p.getInputStream()));
          String line = buf.readLine();
          while (line != null) {
              System.out.println(line);
              line = buf.readLine();
          }
       }
    }
    
    

    Unfortunately, can’t seem to get it working with --exec, so you’re going to have to do some more research there.

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

Sidebar

Related Questions

I'm trying to run genhtml using perl.exe from Cygwin in Windows. I have installed
I have a windows build environment using cygwin and GCC, and am linking to
I am using cygwin on Windows 7 . I have a directory with all
I am using cygwin libraries to run C and C++ programs on Windows. gcc
I'm using Windows XP, TortoiseGit (latest version) and Cygwin. I have git.exe installed and
I have a shell script that will let me access global variables inside the
I am having some difficulties installing jri using cygwin in Windows 7 64 bit
I have a batch script that prompts a user for some input then outputs
I want to get the process memory Info in C. I am using Cygwin
I am compiling a YACC file using Cygwin shell on a PC. I am

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.