If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > How to hide password when executing batch file on Windows and need user interact?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-15-07, 04:32
grofaty grofaty is offline
Registered User
 
Join Date: Jan 2003
Posts: 1,570
How to hide password when executing batch file on Windows and need user interact?

Hi,

On Windows XP SP2 using DB2 WSE v8.2 FP9 I have written batch file to get 'create table' syntax by executing db2look command. The problem is how to hide password during user entering in it on screen?

Question: how to hide password?



One solution is at Google groups and it is working well if Windows CMD is used, but using DB2CMD command it just mess the things up.

Code:
@echo off

rem ================  'Get password not displayed on screen' ==============
echo hP1X500P[PZBBBfh#b##fXf-V@`$fPf]f3/f1/5++u5>in.com
set /p password=Enter database password:<nul
for /f "tokens=*" %%i in ('in.com') do (
                                        set password=%%i

                                        rem Display 'i' and 'password' variables
                                        echo %%i
                                        echo %password%
                                        )
del in.com
rem ================  End of 'Get password not displayed on screen' =======

rem Execute db2look command
db2look -d sample -e -nofed -z tabschema -t tab1 -i db2admin -w %password%
Note: in.com is assembler program which hides password.
Executing above batch file it produces the following output:
Code:
Enter database password:‰>!–»—€>–abc
ECHO is off.
The filename, directory name, or volume label syntax is incorrect.
But executing the sam batch file again it works fine, without any problem.

Why are there "‰>!–»—€>–" charachter executing when batch file is executed first time and no special characters on second time?

Is there any other way to hide password?

Thanks,
Grofaty
Reply With Quote
  #2 (permalink)  
Old 01-15-07, 17:47
GertK GertK is offline
Registered User
 
Join Date: Nov 2003
Location: Netherlands
Posts: 96
I would use a scripting language like ooRexx to enter the hidden password, but this will depend on your environment and OS if it will suit your need.
Reply With Quote
  #3 (permalink)  
Old 01-16-07, 12:51
grofaty grofaty is offline
Registered User
 
Join Date: Jan 2003
Posts: 1,570
GertK, I would like to have a solution as simple as possible. So the best solution would be using just windows batch file.
Any idea?
Reply With Quote
  #4 (permalink)  
Old 01-16-07, 13:49
GertK GertK is offline
Registered User
 
Join Date: Nov 2003
Location: Netherlands
Posts: 96
If you don't have a problem installing ooRexx (it's free) you can use this script to get the password in a hidden box. If you save this code as db2lk you need to prefix it with rexx when starting.


Code:
-- save as filename db2lk.cmd or db2lk.rex
-- start with rexx db2lk

pwd = PasswordBox("Please enter database password","Security")

-- some password checking using REXX ??

"db2look -d sample -e -nofed -z tabschema -t tab1 -i db2admin -w" pwd 

::requires "OODPLAIN.CLS"
Reply With Quote
  #5 (permalink)  
Old 01-17-07, 01:46
grofaty grofaty is offline
Registered User
 
Join Date: Jan 2003
Posts: 1,570
GertK, thanks for help, but I need to install this RExx on multiple of computers, so I would prefer to be as simple as possible without installing any software.
Grofaty
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On