Computing.Net > Forums > Disk Operating System > Reading input from a batch file

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Reading input from a batch file

Reply to Message Icon

Name: Sumanth Sharma
Date: September 10, 2003 at 05:11:34 Pacific
OS: Windows 2000 Professional
CPU/Ram: P4 2.4GHz / 512 MB
Comment:

How do I input a value using a batch file.
For example, In perl i would say

$input = "";
similairly in a unix shell scrips I will say

read input;

MY QUESTION IS HOW TO ACHIEVE THIS IN MS-DOS
BATCH FILE?

HOPE TO GET SOMETHING FROM U'R EXPERTISE.




Sponsored Link
Ads by Google

Response Number 1
Name: IVO
Date: September 10, 2003 at 05:54:25 Pacific
Reply:

In NT-kernel based systems, Windows NT/2K/XP, you can prompt to get a value to store into an environment variable coding:

Set /P MyVariable=Type in the value

where "Type in the value" is the string displayed at prompt. The characters typed are stored in MyVariable and then processed.

This is not accomplished in DOS-kernel systems, Windows 9X/ME, where some tricks are needed to simulate interactive input.

If you want to know more, type Set /? at command prompt and see the help.

I hope this helps.


0

Response Number 2
Name: Nathan
Date: September 10, 2003 at 16:00:15 Pacific
Reply:

lol I dont think he was asking for user input IVO other wise he would have said his perl code was $var = ;

but thats not what he asked. he wants to just know how to set the value of a variable. and to do so jut do "set myvar=(input here)

keep in mind sumantha that in order to get the variable to show you need to call it within "%" like

set greet=hello
echo %greet%

hope I helped.


0

Response Number 3
Name: Nathan
Date: September 10, 2003 at 16:03:03 Pacific
Reply:

ok it wont show up thanks to computing.net but after the "$var =" is an STDIN in angle brackets.



0

Response Number 4
Name: Sumanth Sharma
Date: September 10, 2003 at 21:27:20 Pacific
Reply:

Yeah u'r right Nathan. I meant

$variable_name ="STDIN"
STDIN - within angled bracket's which I guess get's mistaken to be a HTML tag and since STDIN makes no sense in a HTML tag it did'nt show up.

Coming to the topic I got gold of the "set /p" stuff. Thankzz guys. I could be banging some similair rudimental questions but have patience and pls do answer them.

Thanks again.


0

Response Number 5
Name: nathan
Date: September 11, 2003 at 18:40:36 Pacific
Reply:

keep em comin. sorry i couldnt help i finally relized about 15 minutes later that if it didn't show up for me...

anyway i'm normally help full


0

Related Posts

See More



Response Number 6
Name: jaspreet
Date: September 18, 2003 at 18:41:09 Pacific
Reply:

Well.. i've had similar problems recently..

What i did was convert it by bat2com but there are some limitations in this..

The very huge is that it cannot chech conditions and goto loops accordingly... so i have to check condidiotns and make seperate different .com files files instead of labels !!

Whai i wann achieve here is that actually i pass password to zip files that get extracted.. even though i have concerted it into .com still if anyone opens it in hex, one can easily come to know that the text string after pkunzip -s"MYPASS" is my password..

How do i prevent this ???????????????

Any help is greately appreciated ..

Bye,
Jassi


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Disk Operating System Forum Home


Sponsored links

Ads by Google


Results for: Reading input from a batch file

reading a file from a batch file www.computing.net/answers/dos/reading-a-file-from-a-batch-file/765.html

Display date from a batch file www.computing.net/answers/dos/display-date-from-a-batch-file/2143.html

Detect directory from a batch file.. www.computing.net/answers/dos/detect-directory-from-a-batch-file/4010.html