slicendice
Programmer
Hi
I have a simple batch/command file that I'm using as the mechanism to run some Oracle SQL scripts on Win XP. The script starts off by requesting the user to input the password of an authorised Oracle account. Entering this password is not mandatory - it simply means that a user can run certain admin SQL scripts that they wouldn't otherwise be able to.
What I'm trying to do is present the user with an option if they enter a blank password. So if they just press Enter instead of entering a password when requested, they'll get a message saying "You will not be able to run admin options. Continue anyway? [Y/N]". They can then either enter Y and continue, or enter N and go back and enter a password.
The script I have at the moment is as follows:
This almost works perfectly! The issue is that if I enter no password (i.e. just press enter when password is requested) it asks the question as to whether I want to continue or not OK - but if I select Y (i.e. continue without entering password) then it still loops back and re-asks the question.
The strange thing is, it only does this once - i.e. if I enter no password and select Y to continue a second time, it then works OK and continues as it should.
Can anyone shed any light on why it's doing this?
Thanks very much
I have a simple batch/command file that I'm using as the mechanism to run some Oracle SQL scripts on Win XP. The script starts off by requesting the user to input the password of an authorised Oracle account. Entering this password is not mandatory - it simply means that a user can run certain admin SQL scripts that they wouldn't otherwise be able to.
What I'm trying to do is present the user with an option if they enter a blank password. So if they just press Enter instead of entering a password when requested, they'll get a message saying "You will not be able to run admin options. Continue anyway? [Y/N]". They can then either enter Y and continue, or enter N and go back and enter a password.
The script I have at the moment is as follows:
Code:
:GetPPWD
set /p ppwd=Enter password:
if /i '%ppwd%'=='q' goto End
if /i '%ppwd%'=='' (
echo You will not be able to run admin options
set /p continue=Continue anyway? [Y/N]
if /i '%continue%'=='Y' goto :Next
goto :GetPPWD
)
:Next
etc...
This almost works perfectly! The issue is that if I enter no password (i.e. just press enter when password is requested) it asks the question as to whether I want to continue or not OK - but if I select Y (i.e. continue without entering password) then it still loops back and re-asks the question.
The strange thing is, it only does this once - i.e. if I enter no password and select Y to continue a second time, it then works OK and continues as it should.
Can anyone shed any light on why it's doing this?
Thanks very much