Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: calling .bat from another .bat fails with invalid login. why?  (Read 3002 times)

0 Members and 1 Guest are viewing this topic.

epipko

    Topic Starter


    Newbie

    calling .bat from another .bat fails with invalid login. why?
    « on: October 22, 2009, 11:36:44 AM »
    Hi all,
    I am running batch file (main.bat) from which I call 2 other batch files. Both files have to login to the servers (different servers).
    First file runs fine, but next one fails to login.  I've tried to run second file by itself and it runs just fine. I am not sure if is .bat file "issue".
    Anyone aware of such behavior?

    main.bat
    ----------------
    call batch_1.bat
    call batch_2.bat

    batch_1.bat
    -------------------
    echo Database backup
    rman target user/pwd @<path_to_file_to_run> log <path_to_log_file>

    batch_2.bat
    --------------------
    echo CommVault backup
    qlogin -cs "server_name" -u "user" -p "pwd"
    <some commands here......>

    Thanks,
    Eugene

    billrich

    • Guest
    Re: calling .bat from another .bat fails with invalid login. why?
    « Reply #1 on: October 22, 2009, 03:08:10 PM »
    exit /b  * see below


    C:\>type twobatch.bat
    Code: [Select]
    @echo  off

    call batch_1.bat
    echo return to main after batch one
    call batch_2.bat

    echo return to main after batch two

    pause

    OUTPUT:

    C:\> twobatch.bat
    Database backup
    return to main after batch one
    CommVault backup
    return to main after batch two
    Press any key to continue . . .
    C:\>


    C:\>type  batch_1.bat

    Code: [Select]
    echo Database backup
    rem rman target user/pwd @<path_to_file_to_run> log <path_to_log_file>
    exit /b

    C:\>type  batch_2.bat

    Code: [Select]
    echo CommVault backup

    REM qlogin -cs "server_name" -u "user" -p "pwd"

    exit /b
    C:\>


    *below
    C:\>exit /?
    Quits the CMD.EXE program (command interpreter) or the current batch
    script.


    *below
    EXIT [/B] [exitCode]

      /B          specifies to exit the current batch script instead of
                  CMD.EXE.  If executed from outside a batch script, it
                  will quit CMD.EXE

      exitCode    specifies a numeric number.  if /B is specified, sets
                  ERRORLEVEL that number.  If quitting CMD.EXE, sets the process
                  exit code with that number.

    C:\>

    epipko

      Topic Starter


      Newbie

      Re: calling .bat from another .bat fails with invalid login. why?
      « Reply #2 on: October 22, 2009, 06:04:08 PM »
      Thanks billrich,
      I will give it a try tonight and let you know if it worked.