Specialty Forums
Security and Virus
General Hardware
CPUs/Overclocking
Networking
Digital Photo/Video
Office Software
PC Gaming
Console Gaming
Programming
Database
Web Development
Digital Home

General Forums
Windows XP
Windows Vista
Windows 95/98
Windows Me
Windows NT
Windows 2000
Win Server 2008
Win Server 2003
Windows 3.1
Linux
PDAs
BeOS
Novell Netware
OpenVMS
Solaris
Disk Op. System
Unix
Mac
OS/2

Drivers
Driver Scan
Driver Forum

Software
Automatic Updates

BIOS Updates

My Computing.Net

Solution Center

Free IT eBook

Howtos

Site Search

Message Find

RSS Feeds

Install Guides

Data Recovery

About

Home
Reply to Message Icon Go to Main Page Icon

DOS prompt for user input and loop

Original Message
Name: neuron
Date: March 26, 2005 at 07:52:00 Pacific
Subject: DOS prompt for user input and loop
OS: Win XP
CPU/Ram: 256MB
Comment:
How do I prompt for a user to input an integer in DOS and then execute a loop depending on the number of integer entered ?

Pls help.



Report Offensive Message For Removal


Response Number 1
Name: rogerashley
Date: March 26, 2005 at 08:56:43 Pacific
Subject: DOS prompt for user input and loop
Reply: (edit)
In XP or Standalone DOS ??

DO NOT SHOOT THE MESSENGER


Report Offensive Follow Up For Removal

Response Number 2
Name: neuron
Date: March 27, 2005 at 02:48:07 Pacific
Subject: DOS prompt for user input and loop
Reply: (edit)
In standalone DOS, but the DOS batch will be used in 98se, ME, 2K and XP as well.

Pls help.Thanks.


Report Offensive Follow Up For Removal

Response Number 3
Name: Mechanix2Go
Date: March 27, 2005 at 03:41:24 Pacific
Subject: DOS prompt for user input and loop
Reply: (edit)
Hi,

This should work in most DOS from 5.0 up and in w2k/XP.

::

@echo off > quit.bat
choice /c:123456789 Enter an integer

if errorlevel 9 goto 9
if errorlevel 8 goto 8
if errorlevel 7 goto 7
if errorlevel 6 goto 6
if errorlevel 5 goto 5
if errorlevel 4 goto 4
if errorlevel 3 goto 3
if errorlevel 2 goto 2
if errorlevel 1 goto 1

:9
set NUMloops=*********
goto process

:8
set NUMloops=********
goto process

:7
set NUMloops=*******
goto process

:6
set NUMloops=******
goto process

:5
set NUMloops=*****
goto process

:4
set NUMloops=****
goto process

:3
set NUMloops=***
goto process

:2
set NUMloops=**
goto process

:1
set NUMloops=*
goto process

:process
echo NUMloops=%NUMloops%
set loopNUM=

:loop
if %NUMloops%'==%loopNUM%' quit

::**********************************

:: The thing to be done goes here

::**********************************

set loopNUM=%loopNUM%*
echo %loopNUM%
goto loop

::**

HTH


M2

If at first you don't succeed, you're about average.


Report Offensive Follow Up For Removal

Response Number 4
Name: Mechanix2Go
Date: March 28, 2005 at 06:28:33 Pacific
Subject: DOS prompt for user input and loop
Reply: (edit)
Nobody is obligated to say thank you, but it would be a REAL good idea to at least say if the batch worked.


M2

If at first you don't succeed, you're about average.


Report Offensive Follow Up For Removal

Response Number 5
Name: neuron
Date: March 31, 2005 at 08:56:01 Pacific
Subject: DOS prompt for user input and loop
Reply: (edit)
Hi M2,

Sorry for the late reply.Got tied up with other things @work.

Hey, you're genius! Your script does work for my bath file.I truly got to thank you for saving my day.

Regards,
Smileguy


Report Offensive Follow Up For Removal


Response Number 6
Name: neuron
Date: March 31, 2005 at 09:35:31 Pacific
Subject: DOS prompt for user input and loop
Reply: (edit)
Hi M2,

Sorry again, I would greatly appreciate to learn how can the batch display the number of loops on screen instead of just "*" ?

Thank you in advance.


Report Offensive Follow Up For Removal

Response Number 7
Name: Mechanix2Go
Date: April 1, 2005 at 00:04:31 Pacific
Subject: DOS prompt for user input and loop
Reply: (edit)
Hi,

Modify blocks:

:: OLD
:9
set NUMloops=*********
goto process
::

:: NEW
:9
echo 9
set NUMloops=*********
goto process
::


M2

If at first you don't succeed, you're about average.


Report Offensive Follow Up For Removal

Response Number 8
Name: neuron
Date: April 1, 2005 at 10:01:53 Pacific
Subject: DOS prompt for user input and loop
Reply: (edit)
Thanks M2!

But what i'm referring to will be this portion as shown below:

.
.
.
set loopNUM=%loopNUM%*
echo %loopNUM%
goto loop


How can I possible display %loopNUM% to be shown as the integer instead of '*" ?

Thank you.


Report Offensive Follow Up For Removal

Response Number 9
Name: Mechanix2Go
Date: April 1, 2005 at 10:11:21 Pacific
Subject: DOS prompt for user input and loop
Reply: (edit)
Hi,

In NT we could have cut this down considerably, but to work in DOS, which 'doesn't do' command line math:

::**
if %loopNUM%'==*' echo 1
if %loopNUM%'==**' echo 2
...
::**

It's messy but it works.


M2

If at first you don't succeed, you're about average.


Report Offensive Follow Up For Removal

Response Number 10
Name: neuron
Date: April 2, 2005 at 00:14:14 Pacific
Subject: DOS prompt for user input and loop
Reply: (edit)
Thanks a million, M2!

You have managed to resolved my headache finally!

Regards,
Smileguy



Report Offensive Follow Up For Removal

Response Number 11
Name: neuron
Date: April 2, 2005 at 01:57:27 Pacific
Subject: DOS prompt for user input and loop
Reply: (edit)
Hi M2,

I'm just exploring further improvements on the above batch script.Well, the above script process a user's choice for FTP command (3M file download test , 5 M file download test, etc) and prompt for number of loop to execute.

Well, the above portion has been settled.It works.

However, my main challenge is how to include date and time stampings against their coresponding ftp results and format the output nicely to a text file row by row ?
Eg :
Sat 02/04/05 23:59 - ftp: 2742001 bytes received in 13.69Seconds 200.29Kbytes/sec.
Sat 02/04/05 00:01 - ftp: 2742001 bytes received in 12.23Seconds 235.04Kbytes/sec.
:
:
:

I would greatly appreciate your help in this.

Thanks, M2.



Report Offensive Follow Up For Removal

Response Number 12
Name: neuron
Date: April 2, 2005 at 02:00:12 Pacific
Subject: DOS prompt for user input and loop
Reply: (edit)
For the above, I can settle the date and time stamping output to a text file and also i can use the 'find' command to extract the ftp results and output to the same txt file as the date/time.But, i simply unsure how to format them nicely row by row.

Please help.Thanks.


Report Offensive Follow Up For Removal

Response Number 13
Name: Mechanix2Go
Date: April 2, 2005 at 03:21:50 Pacific
Subject: DOS prompt for user input and loop
Reply: (edit)
Hi,

While you're doing all these looped ftp transfers, and burning up bandwidth, try to keep in mind that folks on the bottom end of the food chain get 5KB/s on the best of days.

Teah, problem is when you echo or pipe the date/time and the find output to a file, each append adds a 'line break'.

CRLF [0d0a hex]

So you need to chop out the 0d0a. To use only DOS/NT it comes down to DEBUG.

So, your choice, DEBUG or a 3rd party utility.


M2

If at first you don't succeed, you're about average.


Report Offensive Follow Up For Removal

Response Number 14
Name: neuron
Date: April 3, 2005 at 01:39:40 Pacific
Subject: DOS prompt for user input and loop
Reply: (edit)
Sorry M2,

But i don't quite understand yr reply.

if i want to use the DOS Debug, how am i going to sort to format my output results row by row?

If it's ok for me to email to you my DOs batch file, i would appreciate it.

Thanks.

Regards,
Smileguy


Report Offensive Follow Up For Removal

Response Number 15
Name: Mechanix2Go
Date: April 3, 2005 at 10:10:41 Pacific
Subject: DOS prompt for user input and loop
Reply: (edit)
Hi SmileGuy,

You're welcome to email your BAT.

15583@dodgeit.com

Either way, we'll 'keep it public'; the assumption being that many others are reading and learning.

Sorry to take so long; had to go to Burma today [!].

Didn't mean to 'baffle with brilliance'
.

Each time you ECHO or PIPE into a file you get, along with the desired text, a 'line break', commonly called CRLF or 0d0a.

So the file 'looks like' separate lines.

This is not what you want. As per you example, you want each line to have:

date time somestring

So we need to get rid of the 'line breaks'.

A third party util works as well but frustrates using the script on a box which does not have the utility. So we'll use DEBUG.

This BAT will put the date and time and the output of your FIND into a file with all that on one line and append it to MYBIG.LOG
***
Does this need to work in NT & DOS?



M2

If at first you don't succeed, you're about average.


Report Offensive Follow Up For Removal

Response Number 16
Name: neuron
Date: April 5, 2005 at 20:10:22 Pacific
Subject: DOS prompt for user input and loop
Reply: (edit)
Hi M2,

I've already emailed the .bat files to your email.

Hope you've received them.

Thank you.

Smileguy


Report Offensive Follow Up For Removal

Response Number 17
Name: Mechanix2Go
Date: April 6, 2005 at 00:05:21 Pacific
Subject: DOS prompt for user input and loop
Reply: (edit)
S g,

Can't connect right now.

I'll keep trying

M2


If at first you don't succeed, you're about average.


Report Offensive Follow Up For Removal

Response Number 18
Name: Mechanix2Go
Date: April 6, 2005 at 01:06:47 Pacific
Subject: DOS prompt for user input and loop
Reply: (edit)
Hi,

I got the mail but it's all junked up with html.

Zip it up and send it to:

15583zip

at

thaiguides

dot

com

M2


If at first you don't succeed, you're about average.


Report Offensive Follow Up For Removal

Response Number 19
Name: neuron
Date: April 7, 2005 at 05:33:03 Pacific
Subject: DOS prompt for user input and loop
Reply: (edit)
Done, hope you got my mail.

Thanks!

Regards,
Smileguy


Report Offensive Follow Up For Removal

Response Number 20
Name: neuron
Date: April 14, 2005 at 23:44:12 Pacific
Subject: DOS prompt for user input and loop
Reply: (edit)
Hi M2,

Any updates from my previous email?

Appreciate your reply.

Thanks a lot.


Report Offensive Follow Up For Removal

Response Number 21
Name: Mechanix2Go
Date: April 15, 2005 at 00:03:40 Pacific
Subject: DOS prompt for user input and loop
Reply: (edit)
Hi smileguy,

I had MailWasher set to block ZIPs.

The filter is now off.

Send your ZIP again.

Regards,

M2


If at first you don't succeed, you're about average.


Report Offensive Follow Up For Removal

Response Number 22
Name: neuron
Date: April 15, 2005 at 00:43:40 Pacific
Subject: DOS prompt for user input and loop
Reply: (edit)
done!
Resend as requested.Pls check if u can receive, yea.

Thanks a lot!


Report Offensive Follow Up For Removal

Response Number 23
Name: Mechanix2Go
Date: April 15, 2005 at 00:51:59 Pacific
Subject: DOS prompt for user input and loop
Reply: (edit)
Hi,

Got it ^ checking it now.

M2


If at first you don't succeed, you're about average.


Report Offensive Follow Up For Removal

Response Number 24
Name: Mechanix2Go
Date: April 15, 2005 at 05:05:11 Pacific
Subject: DOS prompt for user input and loop
Reply: (edit)
Hi,

I'm getting some errors with your bat, but I see the way forward.

This shows all your "FINDs":

find /I "current" time.txt >> R3m.txt
find /I "current" date.txt >> R3m.txt
find /I "Kbytes/sec" d3m.txt >> R3m.txt
find /I "current" time.txt >> R50m.txt
find /I "current" date.txt >> R50m.txt
find /I "Kbytes/sec" d50m.txt >> R50m.txt
find /I "current" time.txt >> R3UP.txt
find /I "current" date.txt >> R3UP.txt
find /I "sent" d3UP.txt >> R3UP.txt

With those FINDs you wind up with lines like"The current..."

When all you really want is the time and date and the ftp result on one line.

The first instance I see where you use %time% is on line #111:

set timestamp=%date% %time%

This will not work in DOS without first setting the TIME var.

If you are setting the TIME & DATE vars separately, we need to know how they are laid out. In particular, it will help to:

echo %time% %date%>TDfile

and report the file size.


M2


If at first you don't succeed, you're about average.


Report Offensive Follow Up For Removal

Response Number 25
Name: neuron
Date: April 15, 2005 at 09:08:06 Pacific
Subject: DOS prompt for user input and loop
Reply: (edit)
Hi M2,

Thanks for yr comment.

Howeveer, I'm aware of the search for my "find" command.But, i'm just wondering how can i format the results into proper row with date/time on the corresponding results?

Also, for the the Kbytes/s , how to convert to kbits/s by multiplying by 8.Can DOS do it?


Report Offensive Follow Up For Removal

Response Number 26
Name: Mechanix2Go
Date: April 16, 2005 at 00:53:00 Pacific
Subject: DOS prompt for user input and loop
Reply: (edit)
Hi SmileGuy,

I'm still not clear on how [or if] you are getting DATE & TIME into vars.

***
echo %time% %date%>TDfile

and report the file size.
***

As to math in DOS, it's pretty much no-go.

M2


If at first you don't succeed, you're about average.


Report Offensive Follow Up For Removal

Response Number 27
Name: neuron
Date: April 16, 2005 at 01:07:49 Pacific
Subject: DOS prompt for user input and loop
Reply: (edit)
Hi M2,


Ideally, i would like my text output to be as follow :-

Sample

-------- S------------ D3M.TXT

Mon 04/04/2005 22:37 hrs - ftp: 2742001 bytes received in 14.57Seconds 188.18Kbytes/sec.

Mon 04/04/2005 22:38 hrs - ftp: 2742001 bytes received in 13.37Seconds 205.10Kbytes/sec.

Mon 04/04/2005 22:39 hrs - ftp: 2742001 bytes received in 13.31Seconds 206.03Kbytes/sec.

Mon 04/04/2005 22:40 hrs - ftp: 2742001 bytes received in 13.63Seconds 201.17Kbytes/sec.

Mon 04/04/2005 22:41 hrs - ftp: 2742001 bytes received in 13.36Seconds 205.24Kbytes/sec.



--------------



Report Offensive Follow Up For Removal

Response Number 28
Name: Mechanix2Go
Date: April 16, 2005 at 01:16:21 Pacific
Subject: DOS prompt for user input and loop
Reply: (edit)
Hi,

Yes, I thought that's where were going.

Don't want to sound like a broken record but we need to get clear about the TIME & DATE vars.

M2


If at first you don't succeed, you're about average.


Report Offensive Follow Up For Removal

Response Number 29
Name: neuron
Date: April 18, 2005 at 19:28:22 Pacific
Subject: DOS prompt for user input and loop
Reply: (edit)
Hi M2,

The DATE & TIME vars are taken from system stamping.

If the way I retrieve my date/time is not refined, I'm open to your suggestion.

Thanks.

Smileguy


Report Offensive Follow Up For Removal

Response Number 30
Name: Mechanix2Go
Date: April 18, 2005 at 23:40:13 Pacific
Subject: DOS prompt for user input and loop
Reply: (edit)
Hi SmileGuy,

Back to #26.

M2


If at first you don't succeed, you're about average.


Report Offensive Follow Up For Removal



Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: DOS prompt for user input and loop 

Comments:

 
  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 


Data Recovery Software




Slow boot time

Trasnferring Documents from old HD

My k8T Neo-v usb's aren't working!

Date Modified = Date Created Time

system files on removable harddrive


The information on Computing.Net is the opinions of its users. Such opinions may not be accurate and they are to be used at your own risk. Computing.Net cannot verify the validity of the statements made on this site. Computing.Net and Computing.Net, LLC hereby disclaim all responsibility and liability for the content of Computing.Net and its accuracy.
PLEASE READ THE FULL DISCLAIMER AND LEGAL TERMS BY CLICKING HERE

All content ©1996-2007 Computing.Net, LLC