I would like to make a simpl开发者_如何学JAVAe batch application that does two things.
- Asks the user to input a name, example "vega"
- Runs "finger vega@mail.example.com" and displays the output of that command.
The following does the first thing, but I am not able to output the result from the finger.
@ECHO OFF
:begin
echo Enter the name of the user you are looking for:
set INPUT=
set /P INPUT=Name: %=%
finger -l %INPUT%@mail.example.com
pause
GOTO begin
Something like this maybe.
@echo off
setlocal
set INTERVAL=10
echo Enter the name of the user you are looking for:
set /P INPUT=
echo INPUT=%INPUT%
echo Name: %INPUT%
:LOOP
for /F "usebackq tokens=*" %%a IN (`finger -l %INPUT%@mail.example.com`) DO set OUTPUT=%%a
echo OUTPUT=%OUTPUT%
if "%OUTPUT%"=="something" (goto LOOPEND)
call :SLEEP %INTERVAL%
goto LOOP
:LOOPEND
goto :eof
:: -------------- Sleep function -------------------
:SLEEP
set /a SECS=%1
set /a SECS+=1
ping 127.0.0.1 -n %SECS% -w 1000 > nul
goto :eof
精彩评论