By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,609 Members | 2,246 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,609 IT Pros & Developers. It's quick & easy.

setting user name password and user name for automating create script

P: 2
hi

I am trying to create the database using a BAT file but the script is not recognizing the username and password sent as parameters and gives error.

The BAT looks like following -

and called as c:\ testit.bat db2admin S0meP@ss123
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------

@Echo Off

set dbuser = %1
set pwd = %2

db2cmd /c /w /i db2 ATTACH TO DB2 USER %dbuser% USING %pwd%
if not %errorlevel% == 0 goto error

db2cmd /c /w /i db2 CREATE DATABASE SAMPLE2
if not %errorlevel% == 0 goto error
Echo " CREATE DB IS DONE..."

:error
echo "Error" >> commands.log
exit

:end
echo "OK" >> commands.log
exit

----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
Aug 17 '07 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.