0

I have a utility which detects DB Vendor name from the configuration file. it is working fine but we have one .ini file for output redirection for this utility.

if i use this utility as cfgtest -v DB_VENDOR > CON:
where CON: is for console redirect. how could I read this data using java?

my old code is working fine without output redirection.

String db_vendor = null;
  _Shell shell = new _Shell();
  /*
   * Parse config.cfg file in order to get Database Vendor.
   */
  String command = "cfgtest -v DB_VENDOR";
  int dstat = shell._execCommand( command );
  String str = shell._getCommandOutput();   
  // VALUE(S): DB_VENDOR=ORA
  String [] st = str.split( "=" );
  db_vendor = st[1].trim();
  return db_vendor;

1 Answers1

0

When you redirect, console output is flushed to file. In essence, Console is empty.

I guess, you need output on both file and console.

you should follow this solution

How to redirect output to a file and stdout

Community
  • 1
  • 1
The Mighty Programmer
  • 1,242
  • 12
  • 23
  • actually, we have one output location file. if in this file some user entry is present then output should be redirected to output file, not stdout. I want to bypass this check and just read output from stdout. –  Nov 21 '16 at 10:21