Solved

user input for batch file

Posted on 2000-02-25
10
779 Views
Last Modified: 2013-12-28
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.
0
Comment
Question by:kuriti_mohan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +4
10 Comments
 
LVL 23

Expert Comment

by:Tim Holman
ID: 2558721
With MS DOS, you had to get Turbobat / Powerbatch to do this.
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.
0
 

Author Comment

by:kuriti_mohan
ID: 2558808
sorry what i mean is i want to know the dos command which is similar to the c language example I gave. Thank U.
0
 
LVL 10

Expert Comment

by:tonnybrandt
ID: 2559900
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.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 4

Expert Comment

by:adam923
ID: 2560130
if you just want to capture one keystroke you can use choice (run help choice from nt command prompt for more info)
0
 
LVL 1

Expert Comment

by:vishone
ID: 2560549

 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
0
 
LVL 4

Expert Comment

by:adam923
ID: 2561402
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?
0
 
LVL 1

Expert Comment

by:vishone
ID: 2562210


 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
0
 

Author Comment

by:kuriti_mohan
ID: 2565352
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.
0
 
LVL 1

Expert Comment

by:ronaldvr
ID: 2569040
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
0
 

Accepted Solution

by:
csabay earned 100 total points
ID: 2590822
Hi, kurti mohan,

look at the following batch file:

@echo Enter your number and a ^Z
@copy ee2.bat + con ee3.bat /b > NUL
@call ee3
@echo %number%

EE2.BAT is a special batch file with the contetnt as follows:

@set number=

Care shuld be taken when creating this batch file. No Carriage Return / Line Feed must be left at the end of the file. Use an editor which does not put these characters to there. E.g. you can use Far's or Norton Commander's F4 built in editor.

The batch works as follows:

prompts for the number
copies EE2.BAT and user input to a scratch name
calls for the actual form to have set the variable NUMBER
echoes the value of NUMBER for sake of control

After this point of the batch you can use the variable NUMBER to have control over your batch.

The one handicap of this solution is that requires the user put a ^Z after his/her input.

I'm sure this will help.

Charles
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, I will show you HOW TO: Install VMware Tools for Windows on a VMware Windows virtual machine on a VMware vSphere Hypervisor 6.5 (ESXi 6.5) Host Server, using the VMware Host Client. The virtual machine has Windows Server 2016 instal…
Configuring Remote Assistance for use with SCCM
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question