Batch file for Recording User Input

Ibm Pc dos 2000 cdrom
March 1, 2010 at 10:20:55
Specs: Windows XP
I'm working on a ping batch file for a restaurant chain that lets us enter a store number, then ping the store...this works fine , but I'd also like a "ping again" option that when prompted, will read back the previous input and ping the same store again. Is this possible? Thanks.

See More: Batch file for Recording User Input

Report •


#1
March 1, 2010 at 10:48:49
"will read back the previous input and ping the same store again"

Can you clarify what this means? What is the previous input? Is it the results of the other ping and if so which part of the results do you want to use?

It sounds like you just need a simple logging system that lets you know when a store is disconnected, is this correct?


Report •

#2
March 1, 2010 at 11:41:41
Thanks for the quick reply :o)

Currently, I'm using the SET command to read user input, in this case a store number, then execute a ping:

Set /P StoreNum=Enter the store number that you'd like to ping:
IF "%StoreNum%"=="21"PING [ip address]
I'd like to add:

Ping again? y/n ...which will then of course, ping the store again...but I'm guessing it would need to have recorded the user input (store number) to a file, then have it read back at the ping again prompt.

All this is to quickly tell if a store's internet connection is good when they call in a issue with credit cards not going thru...thanks again!


Report •

#3
March 1, 2010 at 12:42:42
I'm guessing it would need to have recorded the user input
Psst. You already did. You called it %StoreNum%.

Report •

Related Solutions

#4
March 1, 2010 at 14:32:11
I get that, but yours truely is clueless on how use this variable properly...here's some more explaination: after I get the ping results from the IF/PING statement, I put in a GOTO thusly and so-forth...

:pingagain
SET /P PingAgain=Ping Again? y/n:
IF "%PingAgain%"=="y"
REM ...then ping the same store again
IF "%PingAgain%"=="n" GOTO end
:end
EXIT

...if you could shed some light on what instructions should replace the comment, that'd be great...thanks again :o)


Report •

#5
March 1, 2010 at 14:47:40
I'm . . . still not seeing an issue here. Post your script, and then I might understand why you just can't add a :loop / GOTO loop.

Report •

#6
March 1, 2010 at 15:19:12
Well, leave it to me to screw up a one car parade LOL...here we go...as usual, company names and ip's have been changed to protect the innocent!

@ECHO OFF
COLOR 9A

:begin
CLS
ECHO.
ECHO Welcome to PINGstore
ECHO.
ECHO.
ECHO 1. Company 1
ECHO 2. Company 2
ECHO 3. Company 3
ECHO. 4. Company 4
ECHO.
SET /P Company= Choose a company:
ECHO.
ECHO.
IF "%Company%"=="1" GOTO 1
IF "%Company%"=="2" GOTO 2
IF "%Company%"=="3" GOTO 3
IF "%Company%"=="4" GOTO 4
ECHO.
ECHO.

:1
CLS
ECHO.
ECHO.
Set /P StoreNum= Enter the store number that you'd like to ping:
ECHO.
ECHO.
IF "%StoreNum%"=="21" PING [ip address]
IF "%StoreNum%"=="25" PING [ip address]
IF "%StoreNum%"=="41" PING [ip address]
REM ...plus several more stores
ECHO.
ECHO.
GOTO pingagain

:2
CLS
ECHO.
ECHO.
Set /P StoreNum= Enter the store number that you'd like ping:
ECHO.
ECHO.
IF "%StoreNum%"=="21" PING [ip address]
IF "%StoreNum%"=="23" PING [ip address]
IF "%StoreNum%"=="29" PING [ip address]
REM ...plus several more stores
ECHO.
ECHO.
GOTO pingagain

:3
CLS
ECHO.
ECHO.
Set /P StoreNum= Enter the BRM store number that you'd like ping:
ECHO.
ECHO.
IF "%StoreNum%"=="2" PING [ip address]
IF "%StoreNum%"=="7" PING [ip address]
IF "%StoreNum%"=="9" PING [ip address]
REM ...plus several more stores
ECHO.
ECHO.
GOTO pingagain

:fam
IF "%StoreNum%"=="2468" PING [ip address]
REM ...plus several more stores
ECHO.
ECHO.
GOTO pingagain

:pingagain
SET /P PingAgain= Ping Again? y/n:
ECHO.
ECHO.
IF "%PingAgain%"=="y" GOTO begin
IF "%PingAgain%"=="n" GOTO end
:end
EXIT


Report •

#7
March 1, 2010 at 15:43:08
1) Chage every
PING [ip address]
to
SET ip=[ip address]

2) Change :pingagain to the following:

:pingagain
PING %ip%
SET /P PingAgain= Ping Again? y/n:
ECHO.
ECHO.
IF /I "%PingAgain%"=="y" GOTO pingagain


Report •

#8
March 1, 2010 at 16:04:43
That worked! Thank you very much for your time and knowledge...now to tackle that space/time continuum thing. (be afraid)

Report •

#9
March 1, 2010 at 18:38:11
Reduced to it's essentials:

-------------------------------
@echo off & setLocal EnableDELAYedeXpansion

set /p S=store num ?
:y
ping !S!
set /p A=ping again ?
goto :!A!
:n


=====================================
Helping others achieve escape felicity

M2


Report •

#10
March 4, 2010 at 08:32:23
Very interesting....I shall not delay in researching DELAYedeXpansion!

Report •

#11
March 4, 2010 at 13:34:29
You can if you want, but his script doesn't use it. It's just a part of his batch stub.

Report •

#12
March 4, 2010 at 14:13:14
Looks like thatst only available on Vista and/or 7...for it to work on XP and below, a reg edit would be needed.

Report •

#13
March 4, 2010 at 14:15:05
for it to work on XP and below, a reg edit would be needed.
Incorrect. Case in point, Mechanix2Go has Win2K, has delayed expansion in his stub script, and hasn't bothered to modify his registry.

Report •

#14
March 4, 2010 at 14:43:22
Ok, guess you can't believe EVERYTHING you read on the internet...lol. Got any recommendations for good books/links to batch file programming/windows scripting? I'd really like to get my learn on in this area...thanx loads.

Report •

#15
March 4, 2010 at 23:01:02
For a start, study everything you see here by a helper named IVO.


=====================================
Helping others achieve escape felicity

M2


Report •

Ask Question