Solved

user input for batch file

Posted on 2000-02-25
10
722 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
  • 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
 
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
Why won’t your email signature format correctly?

Struggling to get your corporate email signatures to format correctly? Does the logo keep resizing? Is the text appearing too big? What can you do to prevent this? Find out how you can save your signatures today.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Storage devices are generally used to save the data or sometime transfer the data from one computer system to another system. However, sometimes user accidentally erased their important data from the Storage devices. Users have to know how data reco…
Possible fixes for Windows 7 and Windows Server 2008 updating problem. Solutions mentioned are from Microsoft themselves. I started a case with them from our Microsoft Silver Partner option to open a case and get direct support from Microsoft. If s…
Windows 8 comes with a dramatically different user interface known as Metro. Notably missing from the new interface is a Start button and Start Menu. Many users do not like it, much preferring the interface of earlier versions — Windows 7, Windows X…
In this video, we discuss why the need for additional vertical screen space has become more important in recent years, namely, due to the transition in the marketplace of 4x3 computer screens to 16x9 and 16x10 screens (so-called widescreen format). …

867 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now