Notices
Non Scooby Related Anything Non-Scooby related

DOS command line question..

Thread Tools
 
Search this Thread
 
Old 02 October 2001, 01:19 PM
  #1  
SD
Scooby Regular
Thread Starter
 
SD's Avatar
 
Join Date: Apr 2001
Posts: 678
Likes: 0
Received 0 Likes on 0 Posts
Question

All to be run in Windows NT:

C'mon then you IT guys. My DOS days are long behind me now, but how do I do this?

In a batch file I want to prompt for an input and then pass that input to a variable. For example

"What is your name?"

You would input your name and that would be passed to a variable user_name

Any thoughts?

And I don't want to use Kix to achieve this!

Cheers,

Simon
Old 02 October 2001, 02:29 PM
  #2  
simon_prickett
Scooby Regular
 
simon_prickett's Avatar
 
Join Date: Oct 2000
Posts: 1,013
Likes: 0
Received 0 Likes on 0 Posts
Exclamation

Have done this before with a noddy C program that asks the user the question, which it pulls from a text file, then sets the env variable on exit.

Not sure how to do it just in NT commands - think I got bored of trying and just did it in C.

Simon.
Old 02 October 2001, 03:39 PM
  #3  
fast bloke
Scooby Regular
 
fast bloke's Avatar
 
Join Date: Nov 2000
Posts: 26,619
Likes: 0
Received 0 Likes on 0 Posts
Post

you can do it, but it won't be pretty. You need to ask the question then add each character to a string (which you set to be blank at the start) after checking that it is not return.
You can use a nested If then append statement to do this. Not sure of the syntax but I'm sure someone will have it in seconds
Old 02 October 2001, 04:21 PM
  #4  
SD
Scooby Regular
Thread Starter
 
SD's Avatar
 
Join Date: Apr 2001
Posts: 678
Likes: 0
Received 0 Likes on 0 Posts
Lightbulb

Cheers guys. The simplest things once again made impossible by the man with the bowl haircut.
Old 02 October 2001, 04:35 PM
  #5  
Crispin
Scooby Regular
 
Crispin's Avatar
 
Join Date: Jan 2001
Posts: 534
Likes: 0
Received 0 Likes on 0 Posts
Post

Old 02 October 2001, 04:48 PM
  #6  
Scumbag
Scooby Regular
 
Scumbag's Avatar
 
Join Date: Aug 2001
Posts: 429
Likes: 0
Received 0 Likes on 0 Posts
Thumbs up

Dont know if I'm missing some of your requirements, but try this:

Create a file (Scumbag.bat) in notepad (make sure it as saved under all files not text, otherwise you'll get that sodding .txt extension)

Make a single line entry of :
echo %1 %2

Now invoke the file from DOS as:
Scumbag X Y

This should now take the two values X and Y and feed them into the %1 and %2 variables, and you'll get the echo you require.

You can do this for as many variables as you want, and obviously you'll be wanting to do something more interesting than printing them back to the screen

[and before you ask, God knows where I dragged that from]
Hope this helps

SB
Old 02 October 2001, 04:50 PM
  #7  
Scumbag
Scooby Regular
 
Scumbag's Avatar
 
Join Date: Aug 2001
Posts: 429
Likes: 0
Received 0 Likes on 0 Posts
Post

oops,

just re-read + realised that the above is completely useless if you have already invoked the file

....I'll get me coat
Old 02 October 2001, 05:43 PM
  #8  
carl
Scooby Regular
 
carl's Avatar
 
Join Date: May 1999
Posts: 7,901
Likes: 0
Received 0 Likes on 0 Posts
Post

Scumbag -- if you already have a file that you'd like to append to you can do something like:

echo %1>temp.txt
copy already_invoked_file.txt+temp.txt already_invoked_file.txt

but I think this is diverging from the requirement.

I was going to suggest use of the scankey command, which returns the ASCII value of the entered character into the %errorlevel% variable, but I found this webpage:
Old 02 October 2001, 06:46 PM
  #9  
SD
Scooby Regular
Thread Starter
 
SD's Avatar
 
Join Date: Apr 2001
Posts: 678
Likes: 0
Received 0 Likes on 0 Posts
Thumbs up

Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
Pro-Line Motorsport
Car Parts For Sale
48
21 July 2017 09:50 PM
Ganz1983
Subaru
5
02 October 2015 09:22 AM
Pro-Line Motorsport
Car Parts For Sale
2
29 September 2015 07:36 PM
Pro-Line Motorsport
ScoobyNet General
9
28 September 2015 09:48 PM
Pro-Line Motorsport
Car Parts For Sale
0
27 September 2015 11:23 AM



Quick Reply: DOS command line question..



All times are GMT +1. The time now is 06:36 PM.