Page 1 of 1

Is this possible to be done?

Posted: 14 Mar 2019 07:13
by Robertlio22
Hi,

I would like to Ping the site [LINK REMOVED] every 10 minutes and update a text file with the word "Live" in case of reply and "Down" in case of no reply with date and time.

If it's possible can someone guide me?

Re: Is this possible to be done?

Posted: 14 Mar 2019 09:17
by aGerman

Code: Select all

@echo off &setlocal

set "logfile=pingstat.txt"

for /l %%i in () do (
  >nul ping nonsense.com

  if errorlevel 1 (
    >"%logfile%" echo Down
  ) else (
    >"%logfile%" echo Live
  )

  >nul timeout /t 600 /nobreak
)
Use >>"%logfile%" if "update" means "append" rather than "overwrite".

Steffen

Re: Is this possible to be done?

Posted: 14 Mar 2019 09:34
by Aacini

Code: Select all

@echo off
setlocal EnableDelayedExpansion

set "reply[0]=Down" & set "reply[1]=Live"

(for /L %%i in () do (
   ping nonsense.com >nul
   call echo %%reply[!errorlevel!]%%
) > logfile.txt
Antonio