Results 1 to 5 of 5
  1. #1
    Join Date
    Jan 2003
    Posts
    1,605

    Unanswered: 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

  2. #2
    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.

  3. #3
    Join Date
    Jan 2003
    Posts
    1,605
    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?

  4. #4
    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"

  5. #5
    Join Date
    Jan 2003
    Posts
    1,605
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •