write user input to output file

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
tcurrier
Posts: 3
Joined: 05 May 2011 06:56

write user input to output file

#1 Post by tcurrier » 05 May 2011 07:08

Hi,

I want to prompt a user for input, then write the results to
a file (say, C:\USERINPUT.TXT, for example)

C:\USERINPUT.TXT:
Joe Smith
000-555-1212

Any suggestions on how to do this?

Thanks for any help.

Current code:

Code: Select all

:input
set INPUT=
set /P INPUT=Type Enter your name please : %=%
if "%INPUT%"=="" goto input
echo Your input was: %INPUT%

:input2
set INPUT2=
set /P INPUT2=Type Enter your phone # : %=%
if "%INPUT2%"=="" goto input2
echo Your input was: %INPUT2%     

!k
Expert
Posts: 378
Joined: 17 Oct 2009 08:30
Location: Russia

Re: write user input to output file

#2 Post by !k » 05 May 2011 07:56

>C:\USERINPUT.TXT echo %INPUT%
>>C:\USERINPUT.TXT echo %INPUT2%

tcurrier
Posts: 3
Joined: 05 May 2011 06:56

Re: write user input to output file

#3 Post by tcurrier » 05 May 2011 08:13

Thanks, but I got the following :

'C:\USERINPUT.TXT' is not recognized as an internal or external command,
operable program or batch file.

tcurrier
Posts: 3
Joined: 05 May 2011 06:56

Re: write user input to output file

#4 Post by tcurrier » 05 May 2011 08:29

Just had to rearrange things a little bit ;-)

Code: Select all

echo %INPUT%   >  c:\output_file.txt
echo %INPUT2%  >> c:\output_file.txt


This works ... thanks for your help !

!k
Expert
Posts: 378
Joined: 17 Oct 2009 08:30
Location: Russia

Re: write user input to output file

#5 Post by !k » 05 May 2011 09:49

'C:\USERINPUT.TXT' is not recognized as an internal or external command,
operable program or batch file.

You lost arrows

>C:\USERINPUT.TXT echo %INPUT%
>>C:\USERINPUT.TXT echo %INPUT2%

Post Reply