1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Batch to read password from txt file

Discussion in 'Software Development' started by dampyr, Nov 25, 2011.

Thread Status:
Not open for further replies.
Advertisement
  1. dampyr

    dampyr Thread Starter

    Joined:
    Nov 25, 2011
    Messages:
    23
    I have username and password in txt file-one string.I have batch that run application that require username and password.I want that batch supply username/password from txt file,in variable form:

    sqlplus "username/password" -argument

    So i want that instead "username/password" put variable which will read data from txt file:

    sqlplus @variable -argument.

    I need this because we need to change password every month,and because we need to run more instances of this app (every have it's own batch),i want to change password only once in txt file,not in every batch files

    Thanks in advance
     
  2. Squashman

    Squashman Trusted Advisor

    Joined:
    Apr 4, 2003
    Messages:
    19,786
    set /p userpass=<passwordfile.txt
     
  3. dampyr

    dampyr Thread Starter

    Joined:
    Nov 25, 2011
    Messages:
    23
    Thanks for quick replay:
    so complete code will be:



    set /p userpass=<passwordfile.txt
    sqlplus userpass -argument
    right?
     
  4. Squashman

    Squashman Trusted Advisor

    Joined:
    Apr 4, 2003
    Messages:
    19,786
    I know nothing about SQL.
    If your username and password are on one line in a text file, the code above will put that into a variable with a batch file.
    Code:
    C:\Users\Squash>type passwordfile.txt
    myuser/mypass
    
    C:\Users\Squash>set /p userpass=<passwordfile.txt
    
    C:\Users\Squash>echo %userpass%
    myuser/mypass
    
    C:\Users\Squash>
     
  5. dampyr

    dampyr Thread Starter

    Joined:
    Nov 25, 2011
    Messages:
    23
    Thanks again,yes my username and password are in format username/password,that is whole content of txt file,in single line
     
  6. Sponsor

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/1028397

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice