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

The Archive Base Latest Questions

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

I have a BAT file, which creates a number of csv files by reading

  • 0

I have a BAT file, which creates a number of csv files by reading DB tables. bcp.exe is used for this purpose, thus, for each CSV created from a table, there’s a separate bcp.exe call. All these are found in the BAT file, which I invoke using Runtime.exec().

Now the issue I face is random. It can’t be recreated in developer environment, but occurs once in a while in the production environment.

Sometimes after the BAT file is executed, only few of the CSV files have been created, and the rest is missing. But when you re-execute the same, you get all the CSVs.

Here’s the code:

        String command = "cmd /C " + batFilePath + " " + batParams;
        LOGGER.info("Executing : " + command);
        Runtime rt = Runtime.getRuntime();
        Process process = rt.exec(command);

        process.getInputStream();
        is = process.getInputStream();
        isr = new InputStreamReader(is);
        br = new BufferedReader(isr);

        String line;

        while ((line = br.readLine()) != null) {
            LOGGER.info(line);
        }

Would really appreciate it if anyone can enlighten me on how this might happen, since I am all at sea regarding this.

Thanks in advance,

-Raj.

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

    Just a couple of points.

    The first is that I’ve never understood why Java insists on getting the process’s output stream with getInputStream – that’s just bizarre. But that’s just me ranting, there’s not much you can do about that 🙂

    Secondly, I’m not sure why you have a “naked” process.getInputStream(); in your code. I don’t think it’s bad but it seems unnecessary.

    Thirdly (and, to be honest, this is the only one I think may help), you need to debug the batch file itself rather than your Java code.

    This can be done with the following two suggestions.

    First, get the error stream and look at it. It’s quite possible that cmd is delivering error information which you’re just ignoring.

    Secondly, change the batch file to output copious amounts of debug statements, one after each line if necessary. This will hopefully pinpoint the problem down to a specific place in the batch file.

    If it only happens in production (and intermittently), that’s harder, but we generally find that our customers are more than willing to accept debug-style temporary patches so we can collect the information to fix the problems they’re seeing.

    Output from a batch file which is simply logged is also a low-risk change. Some debug code is not so low-risk and we have to test that very thoroughly before involving the customer production systems. Some will refuse point blank, a not-unwise position to take.

    • 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 batch file which should have this commands: cd c:\Program files\NuSMV\2.5.2\bin\
I have a windows.bat file which is actually my custom installer. When everything is
I have bat-file, that make some operations. How to run this file from Delphi
Hi i have difficulties trying to translate this .sh file to a .bat file.
I have a build.bat file which uses %1 internally... so you might call: build
I have a batch file that creates a scheduled task using schtasks like this:
I have created a bat file which calls selenium server called run-selenium-server.bat which has:
I have a .bat file with certain commands which it executes (XCOPY/DEL/RMDIR,etc) Now what
I have created a jar which needs to be called in a bat file.
I have a .bat file which starts a bunch of processes, ultimately resulting in

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.