'why when executing a bat that uses awk from oracle the process does not finish?

I have developed a batch to remove duplicate rows from a file, for this I have used the awk tool, which I install and configure in the system environment variables: C:\Program Files (x86)\GnuWin32\bin

file bat:

@echo off
set "fecha=%1"
set "inputpath=%2"
set fechaInformacion=%fecha:~2,6%
set file=FICUO%fechaInformacion%.txt
set unique=.uq
awk -v FIELDWIDTHS="3 19 19 3 3 5 12 6 9 40 4 8 13 3 3 3 3 1 3 13 13 13 13 13 13 3 13 2 8 8 8 2 8 6 11 11 11 8 4" "!seen[$1,$2,$6,$8,$9,$12,$16,$17,$33]++" %inputpath%%file% > %inputpath%%file%%unique%

when I execute the bat from cmd, the file is generated empty and when the process ends the file has data.

C:\Users\Administrador>C:\Archivos\ebc\in\clean.bat 20160401 C:\Archivos\ebc\in\

however when I run the bat from oracle using java, the file is created empty but the process never ends.

This the code in oracle:

create or replace and compile java source named shellscript as
public class ShellScript
{
  public static String removeDuplicate(String ruta, String nombre, String fecha) {
     try {
          Process p = Runtime.getRuntime().exec(ruta+nombre + " " + fecha + " " + ruta);
          p.waitFor();
      }catch( java.io.IOException ex ){
          return ex.getMessage();
      }catch( InterruptedException ex ){
          return ex.getMessage();
      }
      return "OK";
  }
};

FUNCTION FNC_DELETED(pva_Directorio IN VARCHAR2, pva_NombreScript IN VARCHAR2, pva_FechaInformacion IN VARCHAR2) RETURN VARCHAR2
    AS LANGUAGE JAVA NAME 'ShellScript.removeDuplicate(java.lang.String, java.lang.String, java.lang.String) return java.lang.String';

SELECT FNC_DELETED(pva_Directorio       => 'C:\archivos\ebc\in\',
                   pva_NombreScript     => 'clean.bat',
                   pva_FechaInformacion => '20160401')
  FROM dual;

What I have been able to identify is that in the first case awk runs inside the cmd but in the second case it seems to run independently.

enter image description here

Any idea why this is happening and how can I fix it?. thanks.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source