Solved

Need to get User Input and validate the input from file

Posted on 2011-02-22
7
392 Views
Last Modified: 2012-05-11
Need to get 3 digit numeric values and validate it with file.  If doesn't match, request input again.

Enter the person ID or Q to Cancel? 123
Match Found, Triggering action

Enter the person ID? 888
Match NOT Found, Please enter again or Q to Cancel.
0
Comment
Question by:sk7815
  • 4
  • 2
7 Comments
 
LVL 9

Accepted Solution

by:
Scottyworld earned 300 total points
ID: 34956675
This will automatically loop if the number is not found in the text file
 
@echo off

:TOP
set /p digits= Enter number: 

findstr /m "%digits%" "c:\support\myfile.txt"
If %errorlevel%==0 (
echo Found number
GOTO END
) else (
Echo Match not found
GOTO TOP
)
:END

Open in new window

0
 
LVL 8

Expert Comment

by:subhashchy
ID: 34956705
you should put your action stuffs after :END in the batch code provided by Scottyworld:
0
 

Author Comment

by:sk7815
ID: 34956903
Thank you, can you add 'Q" or 'q' to exit out.
0
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.

 

Author Comment

by:sk7815
ID: 34956921
may be '000' will work since we setting up as numeric.

@echo off

:TOP
set /p digits= Enter Store Number:

IF %digits% == 000 GOTO END

findstr /m "%digits%" "c:\junk\foo.dat"
If %errorlevel%==0 (
echo Found number
GOTO END
) else (
Echo Match not found
GOTO TOP
)
:END
0
 

Author Comment

by:sk7815
ID: 34956968
When the input value matches the string, it displays the file name.  Can we avoid it?
0
 
LVL 8

Assisted Solution

by:subhashchy
subhashchy earned 100 total points
ID: 34956986
add >nul after this line like this....

findstr /m "%digits%" "c:\support\myfile.txt" >nul
0
 

Author Closing Comment

by:sk7815
ID: 34957021
Great Team!
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

YESTERDAY YESTERDAY.BAT is inspired by a previous article I wrote entitled: TOMORROW.BAT (http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/MS_DOS/A_4196-Advanced-Batch-File-Programming-TOMORROW-BAT.html). The crux of this batch f…
Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

932 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

14 Experts available now in Live!

Get 1:1 Help Now