kuriti_mohan
asked on
user input for batch file
how can i take user input from the keyboard in dos like
"int a; printf("Enter a number:"\n); scnaf("%d",&a)" in c language.
I want to use this DOS comand in a batch file. reply me soon. Urgent.
"int a; printf("Enter a number:"\n); scnaf("%d",&a)" in c language.
I want to use this DOS comand in a batch file. reply me soon. Urgent.
ASKER
sorry what i mean is i want to know the dos command which is similar to the c language example I gave. Thank U.
As Tim writes, there's no standard dos-command that can do what you wants. Since you obviosly know some C langauage, compile a utility yourself. You have almost written it already. That way you can be in control of errorchecking etc.
if you just want to capture one keystroke you can use choice (run help choice from nt command prompt for more info)
Hi kuriti_mohan,
It is possible to prompt for the user input for the
batch file. Probably you can use this method.
For this,
(1) Create a shortcut for the batch file.
(2) In the properties window for the shortcut,
Program tab, Command lIne field, enter a
space and question mark after the command
For example, the command line should look like
<PATH><\BATCHFILENAME> ?
(4) Now if you double click on this short cut, a
small window appears to accept the parameters.
You can refer the parameters inside the batch file
in usual %1, %2 ... convention.
- Vish
vishone:
i don't think this works in nt 4.0. there is no program tab on a shortcut and there is no command line field. which version of windows are you talking about?
i don't think this works in nt 4.0. there is no program tab on a shortcut and there is no command line field. which version of windows are you talking about?
Hi adam923,
The property window for "Short-cut to
MS-DOs Program" will have "Program"
tab. Note that this shortcut properties
is different from other.
The easiest way to create this type of
short cut is to copy the "_DEFAULT" file
that can be found in WINNT folder and
change the command line field to point
to the batch file.
Check the properties for "_DEFAULT"
file for the "Program" Tab
- Vish
ASKER
All the parameters for the batch file can be given at the beginning of executing the batch file. So there is no way to give input while the batch file is running.
You could try 4NT, a shareware product from JPSoft. This program enhances the CMD Batch language considerably.
Website
http://www.jpsoft.com/4ntdes.htm
An alternative solution from the same guys is Take Command which is GUI oriented.
Ronald
Website
http://www.jpsoft.com/4ntdes.htm
An alternative solution from the same guys is Take Command which is GUI oriented.
Ronald
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Under NT, there's no way, unless you compile this C program into a .COM and call the .COM to do the input for you.
http://gearbox.maem.umr.edu/~batch/awk.scripts.user.input1.html
is a helpful link.
It suggests GAWK, but again that's something you need to install on your system.