Announcement

Collapse
No announcement yet.

Skip error in BATCH file and continue to next command.

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Skip error in BATCH file and continue to next command.

    Hi all,
    I have a batch file with commands, which connect to oracle and give me output. When connection is not possible (etc. locked user), error is occured and batch file is not continueing to other commands. Any idea how skip command with error and execute other commands in batch file? Here is batch file. Thanks

    BATCH:
    %comspec% /c sqlplus -S usr/[email protected] @c:\data.sql
    %comspec% /c sqlplus -S usr/[email protected] @c:\data2.sql
    %comspec% /c sqlplus -S usr/[email protected] @c:\data3.sql
    %comspec% /c sqlplus -S usr/[email protected] @c:\data4.sql

  • #2
    Re: Skip error in BATCH file and continue to next command.

    Use %errorlevel%
    Examples here http://www.experts-exchange.com/OS/M..._22153720.html

    Note if you cannot access the link directly, paste it into Google and use their cached mode
    Tom Jones
    MCT, MCSE (2000:Security & 2003), MCSA:Security & Messaging, MCDBA, MCDST, MCITP(EA, EMA, SA, EDA, ES, CS), MCTS, MCP, Sec+
    PhD, MSc, FIAP, MIITT
    IT Trainer / Consultant
    Ossian Ltd
    Scotland

    ** Remember to give credit where credit is due and leave reputation points where appropriate **

    Comment


    • #3
      Re: Skip error in BATCH file and continue to next command.

      Add Start "" leading the commands
      http://forums.petri.com/showthread.php?t=47483

      /Rems

      This posting is provided "AS IS" with no warranties, and confers no rights.

      __________________

      ** Remember to give credit where credit's due **
      and leave Reputation Points for meaningful posts

      Comment


      • #4
        Re: Skip error in BATCH file and continue to next command.

        errorlevel and Start "" not work. I still get error and I have to push any button to continue...
        like this:

        ERROR:
        ORA-01017: invalid username/password; logon denied

        and at this point I need continue to next command in batch...

        Comment


        • #5
          Re: Skip error in BATCH file and continue to next command.

          hmm strange, what type of file is sqlplus?
          try,
          Code:
          @echo off
          start "" cmd.exe /c "echo.|sqlplus.exe -S usr/[email protected] @c:\data.sql"
          start "" cmd.exe /c "echo.|sqlplus.exe -S usr/[email protected] @c:\data2.sql"
          start "" cmd.exe /c "echo.|sqlplus.exe -S usr/[email protected] @c:\data3.sql"
          start "" cmd.exe /c "echo.|sqlplus.exe -S usr/[email protected] @c:\data4.sql"
          Is there a special reason for using %comspec% /c (= cmd.exe /c ) in the above commands, which is opening a new dos box for each sqlplus commmand?

          Else,
          Code:
          cmd.exe /c start "" sqlplus.exe -S usr/[email protected] @c:\data.sql
          (here, in the second sample, is cmd /c required only when the command is not lauched from a dos prompt or dos batch)


          /Rems
          Last edited by Rems; 10th June 2011, 21:53.

          This posting is provided "AS IS" with no warranties, and confers no rights.

          __________________

          ** Remember to give credit where credit's due **
          and leave Reputation Points for meaningful posts

          Comment


          • #6
            Re: Skip error in BATCH file and continue to next command.

            You might want to add /WAIT to the start line:

            start "" /WAIT cmd.exe /C .......

            Otherwise all 4 sql calls should run at the same time, which might cause issues with other users in the system.

            Usually won't matter, but ti depends how often you do this.

            Hobie

            Comment

            Working...
            X