1.

Solve : calling .bat from another .bat fails with invalid login. why??

Answer»

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 @ log

batch_2.bat
--------------------
echo CommVault backup
qlogin -cs "server_name" -u "user" -p "pwd"


Thanks,
Eugene
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 @&LT;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 /bC:\>


*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:\>Thanks billrich,
I will give it a try tonight and LET you know if it worked.



Discussion

No Comment Found