Topic
  • 14 replies
  • Latest Post - ‏2014-08-14T20:22:14Z by jvanboga
jvanboga
jvanboga
419 Posts

Pinned topic Error calling batch script

‏2014-07-01T12:01:43Z |

Windows XP and WinSvr 2012...

I am converting a map from 8.1 to 8.4 that executes batch files that calls an SQLLDR scripts.  In 8.1 it works without issue, 8.4 is failing.  Here is the simplified rule...

  VALID(GET("BAT","-CMD c:\path\header.bat  -trace -audit"), FAIL("HEADER: " + LASTERRORMSG()))

This is the cmd line in the batch file.....

  sqlldr id/pw@sid  control=header.ctl log=c:\path\header_db_load.log bad=c:\path\header_db_load.bad

The log file indicates one row was inserted to the table...

  Table FND_MAPTOOL_HEADER:
    1 Row successfully loaded.
    0 Rows not loaded due to data errors.
    0 Rows not loaded because all WHEN clauses were failed.
    0 Rows not loaded because all fields were null.
  Space allocated for bind array:                 255420 bytes(18 rows)
  Read   buffer bytes: 1048576
  Total logical records skipped:          0
  Total logical records read:             1
  Total logical records rejected:         0
  Total logical records discarded:        0

 

I confirmed the row was inserted but the map fails with the following issue in the m4batch.mtr file...

  Executing Command: c:\path\HEADER.BAT
  Window Style is SW_HIDE (0).
  Getting standard input handle.
  Standard input handle is 00000000.
  Process 4384 Created.
  Reading from Standard Error...
  stdin reading is being processed by thread 5128.
  ...0 bytes read from Standard Error.
  PeekNamedPipe : When Reading From Stderr returned 6 - The handle is invalid.

  Peeking/Reading from Standard Error failed (err code = 6)...
  Error Executing Command - Return Code is 6.
  Run Terminated at time_stamp....

 Any idea why I'm getting the error?

Updated on 2014-07-02T07:29:49Z at 2014-07-02T07:29:49Z by paul.brett
  • paul.brett
    paul.brett
    778 Posts
    ACCEPTED ANSWER

    Re: Error calling batch script

    ‏2014-07-30T11:37:27Z  
    • jvanboga
    • ‏2014-07-07T13:55:47Z

    Looks like its less about the sqlldr command and more about the batch file execution.  I created a quick, dumb, map that executes a batch file deleting a text file.  Produces same results.  Batch file executed successfully, bad return code.  Here's a copy of the mapset (as you'll see I tried several options)...
     

    I successfully used this testcase, with a slight modification to the batch file:

    del delete_this_file_1.txt

    to

    @del delete_this_file_1.txt
    @echo Done!
     

    ....as the batch file *MUST* provide some output on stdout.

    Let me know if you get a different result.

    Thanks

    Paul

    Follow me on Twitter

    Updated on 2014-07-30T11:40:01Z at 2014-07-30T11:40:01Z by paul.brett
  • paul.brett
    paul.brett
    778 Posts

    Re: Error calling batch script

    ‏2014-07-02T07:29:38Z  

    There are a couple of things you could try here:

     

    1.  Add a couple of echo statements into your batch, so that something is returned to your map.  Something like 'echo Starting load...' before your current line, and 'Load complete...' after your current line.

    2.  Add a pause command at the very end of the script.  Usually, 'pause 1' is sufficient to work around these timing issues.

    Let us know if either one of these or a combination of both works for you.

    Thanks

    Paul

    Follow me on Twitter

  • jvanboga
    jvanboga
    419 Posts

    Re: Error calling batch script

    ‏2014-07-02T13:09:03Z  

    There are a couple of things you could try here:

     

    1.  Add a couple of echo statements into your batch, so that something is returned to your map.  Something like 'echo Starting load...' before your current line, and 'Load complete...' after your current line.

    2.  Add a pause command at the very end of the script.  Usually, 'pause 1' is sufficient to work around these timing issues.

    Let us know if either one of these or a combination of both works for you.

    Thanks

    Paul

    Follow me on Twitter

    'pause n' doesn't work....  changed the batch file script to:

    @echo off
    echo start loading
    sqlldr id/pw@sid  control=header.ctl log=c:\path\header_db_load.log bad=c:\path\header_db_load.bad
    pause 15
    echo load complete


    Didn't pause either.  Seems less specific to DOS and more specific to the 8.4

     

     

    Updated on 2014-07-02T13:10:04Z at 2014-07-02T13:10:04Z by jvanboga
  • jvanboga
    jvanboga
    419 Posts

    Re: Error calling batch script

    ‏2014-07-02T13:18:38Z  

    There are a couple of things you could try here:

     

    1.  Add a couple of echo statements into your batch, so that something is returned to your map.  Something like 'echo Starting load...' before your current line, and 'Load complete...' after your current line.

    2.  Add a pause command at the very end of the script.  Usually, 'pause 1' is sufficient to work around these timing issues.

    Let us know if either one of these or a combination of both works for you.

    Thanks

    Paul

    Follow me on Twitter

    FYI:

    BEGIN BATCH AUDIT - VERSION 8.4.1(37) [1.1.5]
     

  • paul.brett
    paul.brett
    778 Posts

    Re: Error calling batch script

    ‏2014-07-02T13:26:58Z  
    • jvanboga
    • ‏2014-07-02T13:18:38Z

    FYI:

    BEGIN BATCH AUDIT - VERSION 8.4.1(37) [1.1.5]
     

    My mistake, it should be 'sleep 15' not 'pause 15'

    Thanks

    Paul

    Follow me on Twitter

  • jvanboga
    jvanboga
    419 Posts

    Re: Error calling batch script

    ‏2014-07-02T13:53:19Z  

    My mistake, it should be 'sleep 15' not 'pause 15'

    Thanks

    Paul

    Follow me on Twitter

     PID    rc   Size   Time  Retry
    -----  ----  -----  ----  -----
    7688     6   000    001     1 

    Error Messages (96 bytes):
    'sleep' is not recognized as an internal or external command,
    operable program or batch file.


    END BATCH AUDIT
     

  • Tim Rabbitt
    Tim Rabbitt
    52 Posts

    Re: Error calling batch script

    ‏2014-07-02T14:19:47Z  
    • jvanboga
    • ‏2014-07-02T13:53:19Z

     PID    rc   Size   Time  Retry
    -----  ----  -----  ----  -----
    7688     6   000    001     1 

    Error Messages (96 bytes):
    'sleep' is not recognized as an internal or external command,
    operable program or batch file.


    END BATCH AUDIT
     

    Hello:

    You can also try the TIMEOUT command.  This will work with Windows 2012 but it may not work with XP.

    http://serverfault.com/questions/432322/how-to-sleep-in-a-batch-file

    Sleep will work as Paul suggested if you've downloaded it

    Regards,

    Tim Rabbitt

  • jvanboga
    jvanboga
    419 Posts

    Re: Error calling batch script

    ‏2014-07-02T14:22:58Z  

    My mistake, it should be 'sleep 15' not 'pause 15'

    Thanks

    Paul

    Follow me on Twitter

    PS: I also tried running the example that installed with 8.4.1.  Created the table using the script and it failed for the same reason....  Our oracle client is 11.

    path\examples\adapters\oracle\bulkcopy\oracle9

  • paul.brett
    paul.brett
    778 Posts

    Re: Error calling batch script

    ‏2014-07-02T15:26:00Z  
    • jvanboga
    • ‏2014-07-02T14:22:58Z

    PS: I also tried running the example that installed with 8.4.1.  Created the table using the script and it failed for the same reason....  Our oracle client is 11.

    path\examples\adapters\oracle\bulkcopy\oracle9

    Does the script run outside of WTX ?

    Thanks

    Paul

    Follow me on Twitter

  • jvanboga
    jvanboga
    419 Posts

    Re: Error calling batch script

    ‏2014-07-02T18:06:18Z  

    Hello:

    You can also try the TIMEOUT command.  This will work with Windows 2012 but it may not work with XP.

    http://serverfault.com/questions/432322/how-to-sleep-in-a-batch-file

    Sleep will work as Paul suggested if you've downloaded it

    Regards,

    Tim Rabbitt

    Downloaded sleep.exe and the script did sleep for the set time.  The map still failed.  Same reason.

  • jvanboga
    jvanboga
    419 Posts

    Re: Error calling batch script

    ‏2014-07-02T18:09:45Z  

    Does the script run outside of WTX ?

    Thanks

    Paul

    Follow me on Twitter

    Yes, If I run the script from my machine from a DOS prompt it works.  It also works when executing it with WTX8.1. 

    I also tried using the 8.1 m4batch.dll.  That didn't help.   Reverted to the 8.4 dll. 

  • paul.brett
    paul.brett
    778 Posts

    Re: Error calling batch script

    ‏2014-07-03T15:30:13Z  

    Please change:

    sqlldr id/pw@sid  control=header.ctl log=c:\path\header_db_load.log bad=c:\path\header_db_load.bad

    to

    start sqlldr id/pw@sid  control=header.ctl log=c:\path\header_db_load.log bad=c:\path\header_db_load.bad

    ...and retry.  If that doesn't work, I think you'll have to open a Service Request (PMR) with IBM WTX Client Support.

    Thanks.

    Paul

    Follow me on Twitter

    Updated on 2014-07-04T14:40:32Z at 2014-07-04T14:40:32Z by paul.brett
  • jvanboga
    jvanboga
    419 Posts

    Re: Error calling batch script

    ‏2014-07-07T13:55:47Z  

    Please change:

    sqlldr id/pw@sid  control=header.ctl log=c:\path\header_db_load.log bad=c:\path\header_db_load.bad

    to

    start sqlldr id/pw@sid  control=header.ctl log=c:\path\header_db_load.log bad=c:\path\header_db_load.bad

    ...and retry.  If that doesn't work, I think you'll have to open a Service Request (PMR) with IBM WTX Client Support.

    Thanks.

    Paul

    Follow me on Twitter

    Looks like its less about the sqlldr command and more about the batch file execution.  I created a quick, dumb, map that executes a batch file deleting a text file.  Produces same results.  Batch file executed successfully, bad return code.  Here's a copy of the mapset (as you'll see I tried several options)...
     

    Attachments

  • paul.brett
    paul.brett
    778 Posts

    Re: Error calling batch script

    ‏2014-07-30T11:37:27Z  
    • jvanboga
    • ‏2014-07-07T13:55:47Z

    Looks like its less about the sqlldr command and more about the batch file execution.  I created a quick, dumb, map that executes a batch file deleting a text file.  Produces same results.  Batch file executed successfully, bad return code.  Here's a copy of the mapset (as you'll see I tried several options)...
     

    I successfully used this testcase, with a slight modification to the batch file:

    del delete_this_file_1.txt

    to

    @del delete_this_file_1.txt
    @echo Done!
     

    ....as the batch file *MUST* provide some output on stdout.

    Let me know if you get a different result.

    Thanks

    Paul

    Follow me on Twitter

    Updated on 2014-07-30T11:40:01Z at 2014-07-30T11:40:01Z by paul.brett
  • jvanboga
    jvanboga
    419 Posts

    Re: Error calling batch script

    ‏2014-08-14T20:22:14Z  

    FYI - Resolved.  We built another W2012 server and were able to successfully run the maps executing the batch files via our scheduler.  We'll be rebuilding our other, related, servers over the next few days.

     

    Thanks for the help.