开发者

Creating a simple finger application with batch

开发者 https://www.devze.com 2023-01-09 00:04 出处:网络
I would like to make a simpl开发者_如何学JAVAe batch application that does two things. Asks the user to input a name, example \"vega\"

I would like to make a simpl开发者_如何学JAVAe batch application that does two things.

  1. Asks the user to input a name, example "vega"
  2. 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

0

精彩评论

暂无评论...
验证码 换一张
取 消