Bob,

Is it really a DOS batch file or is it 95 or NT4 or W2K / XP - or does it need to run 
on all of them?
This is important as the options vary.

Anyway, below is a copy of a post I made in March 2002 describing some of the options:

HTH,
Bruce Reardon

"In W2K it is easy, you can use set/p - type set/? to get the help and see below.
H:\>set/p  fred=[input value for fred]
[input value for fred]oracleis?

H:\>echo %fred%
oracleis?

H:\>


Or you can call sqlplus and have sqlplus do the prompting and then have it host out to 
the bat file and pass in the parameters.
Or you could Perl or a Unix emulator or I imagine their are many shareware / freeware 
utilities.

Under NT4 other options are not easy and I have listed a number of ways and links that 
show how you can achieve this:

Or from a Tom Lavedas posting on the newsgroup alt.msdos.batch.nt
        (dated Tue, 05 Jun 2001 09:04:04 -0400  entitled "prompting for a parameter"
"
Old problem - batches were initially assumed to run unattended -
therefore, there was no need for user interaction.  However, in the
PC/Windows environment, they are useful for scripting many redundant
tasks, even some that require/benefit user interaction.
 
MS finally added recognized this fact by adding the /P (prompt)
functionality to the SET statement in Win 2000 (but not before that).
So, if you are in a pure Win 2000 environment, type SET/? at a command
prompt to get information on the use of the /P switch.
 
If you are using NT 4 or are in a mixed NT/2000 environment, there is no
'perfect' solution.  I have been interested in the subject of user input
for a long time and have developed and collected various techniques,
which I offer for your consideration:
 
1.  Get a third party utility like, Strings.com from PC Magazine,
    (e.g. see ftp://ftp.zdnet.com/pcmag/1992/1222/strings.zip) -
    recently reported to be broken in NT.  A third party utility is
    probably the most viable solution for use in Win NT, though
    AFAIK all of the little utilities out there were written for
    the original DOS (pre-NT).  See http://www.Simtel.net
 
2.  Another NT approach, posted by Bennett Benson, is explained at
    this link:  http://www.jsiinc.com/TIP0300/rh0323.htm
                [this doesn't seem to be working as at 1-Mar-2002]
 
3.  Write a Win Script Host script using the InputBox function
    (requires Win 98, Win NT 4.0, IE 5 or a free download from MS),
 
    For example ...
 
          Dim Input
          Input = InputBox("Enter your name")
          MsgBox ("You entered: " & Input)
 
    (see http://msdn.microsoft.com/scripting/default.htm to get
    started)
 
4.  A variation on the theme of 3 above is a hybrid WSH script/batch
    function
 
:: InWSH.bat - A WSH/Batch hybrid string input routine.
::             Requires Windows Script Host version 1.0 or later.
::             Use optional command line argument UCASE to convert
::             input to all uppercase or LCASE for lowercase.
::             With WSH V2+, EVAL allows math operations, as well.
:: Tom Lavedas <[EMAIL PROTECTED]>
::             http://www.pressroom.com/~tglbatch/
 @echo off
  Set _T=%temp%\~tmp
  echo Set oFS=CreateObject("Scripting.FileSystemObject")>%_T%.vbs
  Echo oFS.OpenTextFile("CON",2).Write "Enter a string: ">>%_T%.vbs
  echo S=%1(Trim(oFS.OpenTextFile("CON",1).Readline))>>%_T%.vbs
  echo Wscript.Echo "set Input="+CStr(S)>>%_T%.vbs
  cscript.exe //nologo %_T%.vbs > %_T%.bat
  for %%v in (%_T%.bat del) do call  %%v %_T%.???
  set _T=
  % For Example % echo You typed %Input%
 
  If you call this with a single command line parameter of Ucase or
  LCase, it will return the string input by the user in the
  appropriate case.  If you have WSH v5.1+ and use EVAL as the command
  line argument, it will do math operations as well, as in ....
 
C:\> inwsh eval
Enter a string: 11 * 12
You typed 132
 
  This approach will work with Win 98 and Win 2000 and probably NT
  right out of the box.
 
5.  In Win2K the following works:
 
  SET /P variable=[promptString]
 
6. Finally, this NT specific approach, originally given by Walter
   Zachery, improved and supplied by Clay Calvert, ....
 
  @echo off
  echo.
  echo Enter Input:
  for /f "tokens=*" %%a in (
    'format/f:160 a: ^|find "..."') do set Input=%%a
  set Input=%Input:~30%
 
  This approach will spin the floppy drive, but won't change
  anything.  The drive does not need to be occupied.
---------------------------------------------------------------
 
Tom Lavedas http://www.pressroom.com/~tglbatch/
"


I have seen a web site showing how to do it using label (similar to the format 
command).
 
You Can also use choice command - available from 
ftp://ftp.microsoft.com/Services/TechNet/Windows/msdos/RESKIT/suppdisk/choice.com

And from another alt.msdos.batch.nt posting:
"
Date:   Tue, 20 Feb 2001 16:28:40 -0800 
...
Here's one way that will work in WinNT4.0.  If you are using Win2000,
you can use 'SET /P' instead.
 
==========begin file C:\cmd\TEST\ZZZINPUT.CMD ==========
001. @echo off
002. echo.
003. call rdstring ZQusername   "Please enter your name:"
004. call rdstring ZQuserphone  "Phone:"
005. call rdstring ZQaddress1   "Street Address:"
006. call rdstring ZQcity       "City:"
007. call rdstring ZQstate      "State:"
008. call rdstring ZQZip        "ZIP Code:"
009. set ZQ
010. goto :EOF
011. :EOF
==========end   file C:\cmd\TEST\ZZZINPUT.CMD ==========
 
==========begin file C:\cmd\TEST\RDSTRING.CMD ==========
001. @echo off
002. ::
003. :: based on method originally provided by Walter Zachary
004. :: and modified by Tom Lavedas
005. ::
006. :: syntax: call rdstring (varname) "your prompt in double quotes"
007. ::
008. setlocal
009. set target=%1
010. set myprompt="""%2"""
011. set myprompt=%myprompt:""""=%
012. echo.
013. echo %myprompt%
014. for /f "tokens=*" %%a in (
015.   'format/f:160 a: ^|find "..."') do set input=%%a
016. set input=%input:~30%
017. endlocal&set %target%=%input%&goto :EOF
018. :EOF
019.
==========end   file C:\cmd\TEST\RDSTRING.CMD ==========
"
 
eg 1 "convoluted" freeware option is to use ask from http://www.kik-it.com to put the 
response into a text file and then parse that with for command.
"

HTH,
Bruce Reardon

-----Original Message-----
Sent: Friday, 12 July 2002 7:34

You could use utility "choice.exe" (I think it comes with NT Resource Kit).
Here is an example of the batch file:

echo off
choice /c:YN Do you want to Continue ?
if errorlevel 2 goto end 

rem do whatever you need here
...........................................
..........................................
:end
echo End of processing.


Obviously "N" answer returns "errorlevel 2".


Igor Neyman, OCP DBA
[EMAIL PROTECTED]
  


----- Original Message ----- 
To: "Multiple recipients of list ORACLE-L" <[EMAIL PROTECTED]>
Sent: Thursday, July 11, 2002 4:37 PM


> All,
> 
> I have a DOS batch file. In between this script, I
> would like to add user interactive question.
> 
> Ex: Do you want to Continue [Y/N]?
> 
> Once they hit "Y", it will continue rest of the batch
> file.
> 
> Could someone able to help me out as per the above
> requirement?
> 
> Thanks,
> Bob
--
Please see the official ORACLE-L FAQ: http://www.orafaq.com
--
Author: Reardon, Bruce (CALBBAY)
  INET: [EMAIL PROTECTED]

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).

Reply via email to