Forum Moderators: open

Message Too Old, No Replies

Batch File Syntax

how do I add a password?

         

txbakers

1:56 am on May 15, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I have a batch file that updates a database. The login requires a password. What is the syntax to 'write" to the command line in the batch file.

THANKS.

Brett_Tabke

2:11 am on May 15, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



What kind of database? SQL? Access?
Is it local or remote?

txbakers

2:48 am on May 15, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



it's running a local mysql command to reset some variables, not data.

My batch file at the moment is:
D:
cd mysql\bin
mysql -u root -p < kb.txt
quit

after the mysql line it asks for a password so I tried this:

D:
cd mysql\bin
mysql -u root -p < kb.txt
pass4567
quit

but it didn't read that.
Do I need to program a 'wait" in there, or is there a syntax for answering interactive questions like that?

bill

4:39 am on May 15, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



It's not very secure, but you can put the password in directly after the -p switch.

D: 
cd mysql\bin
mysql -u root -p[b]pass4567[/b] < kb.txt
quit

If you leave the -p switch with nothing after it (as you have above) then it will prompt for the password manually.

txbakers

11:40 am on May 15, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



That did it, thanks.