Computer Hope

Microsoft => Microsoft Windows => Windows 10 and 11 => Topic started by: Santosh on April 06, 2020, 08:25:04 AM

Title: I need to create a batch file, which should give me output and send emails
Post by: Santosh on April 06, 2020, 08:25:04 AM
I need to create a batch file which will be containing the URLs, which should give me output and send emails for only "DOWN" status of the URL's with specific message . Like HTTP/1.1 200ok and HTTP/1.1 503 Service unavailable
Title: Re: I need to create a batch file, which should give me output and send emails
Post by: Santosh on April 08, 2020, 03:18:52 AM
Dear All,

I need to create a batch file, which should first ping CURL to the different api endpoint URL address, if it gets HTTP bad response from any of them, it should send mail with specific message. Your swift response would be highly appreciated.

Thanks in advance
Title: Re: I need to create a batch file, which should give me output and send emails
Post by: Geek-9pm on April 08, 2020, 10:20:13 AM
Either your or somebody made a similar request. The forum does not help with jibs that might be in violation of rules. Mass e-mail is considered as a job that might break rules.
Title: Re: I need to create a batch file, which should give me output and send emails
Post by: Santosh on April 08, 2020, 10:59:43 AM
Yes I am making a request to [email protected].
Title: Re: I need to create a batch file, which should give me output and send emails
Post by: Santosh on April 13, 2020, 07:16:57 AM
I have a text file containing multiple API URLs. Now I want to call them one by one in our batch file and execute and send notification via BLAT if it is not pinging. Your response will be so helpfull. PLease help us in resolving this.
Title: Re: I need to create a batch file, which should give me output and send emails
Post by: Hackoo on April 13, 2020, 12:45:04 PM
I have a text file containing multiple API URLs. Now I want to call them one by one in our batch file and execute and send notification via BLAT if it is not pinging. Your response will be so helpfull. PLease help us in resolving this.
Can you post what did you tried as code and some examples of URLs to test them ?
Title: Re: I need to create a batch file, which should give me output and send emails
Post by: Santosh on April 13, 2020, 10:32:25 PM
Yes I have tried like this, I have a text file containing multiple URLs. EX: URL.txt containing www.google.com and so on...
Now from my batch file I want to call them one by one sequentially, curl -i  %%I in URL.txt, and the output should be redirected to a text file only if it is not pingable.
Title: Re: I need to create a batch file, which should give me output and send emails
Post by: Santosh on April 14, 2020, 10:47:22 PM
Your quick response will be appreciated.
Title: Re: I need to create a batch file, which should give me output and send emails
Post by: Hackoo on April 15, 2020, 04:42:06 AM
Hi ;)
Since you didn't provide us any code to deal with, i come with my solution !
First open your notepad and copy and paste this code below as CheckURL.vbs

The vbscript : CheckURL.vbs
Code: [Select]
Option Explicit
Dim Not_OK_URLS, oARG, OK_URLS
OK_URLS = "OK_URLS.txt"
Not_OK_URLS = "Not_OK_URLS.txt"
Set oARG=WScript.Arguments
If oARG.Count=0 Then WScript.Quit
wscript.echo Check(oARG(0))
'---------------------------------------------------------------------------------------------------
Function Check(URL)
On Error Resume Next
Const WHR_EnableRedirects = 6
Dim h,AllResponseHeaders
Set h = CreateObject("WinHttp.WinHttpRequest.5.1")
h.Option(WHR_EnableRedirects) = False 'disable redirects
h.Open "HEAD", URL , False
h.Send()
'AllResponseHeaders = h.GetAllResponseHeaders()
'wscript.echo AllResponseHeaders
If Err.number = 0 Then
Select Case CInt(h.status)
Case 200,201,202,204
Check = h.status & vbTab & h.statusText
Call WriteLog(URL & vbTab & Check & vbCrlf & String(100,"-"),OK_URLS)
Case 404,401,403,412,415,500,501,500,503
Check = h.status & vbTab & h.statusText
Call WriteLog(URL & vbTab & Check & vbCrlf & String(100,"-"),Not_OK_URLS)
Case Else
Check = h.status & vbTab & h.statusText
Call WriteLog(URL & vbTab & Check & vbCrlf & String(100,"-"),Not_OK_URLS)
End Select
Else
Check = "OFFLINE" & vbCrlf &_
"Error Description: " & Err.Description
Call WriteLog(URL & vbTab & Check & vbCrlf & String(100,"-"),Not_OK_URLS)
On Error Goto 0
End IF
End Function
'---------------------------------------------------------------------------------------------------
Sub WriteLog(strText,LogFile)
Const ForAppending = 8
Dim fs,ts
Set fs = CreateObject("Scripting.FileSystemObject")
Set ts = fs.OpenTextFile(LogFile,ForAppending,True)
ts.WriteLine strText
ts.Close
End Sub
'---------------------------------------------------------------------------------------------------

And copy and paste this code too with your notepad in the same folder as the vbscript above and name it as CheckURL.bat

The Batch Script : CheckURL.bat
Code: [Select]
@echo off
Title Check URLS by Hackoo 2020 & Color 0A
set "URLs=URLs.txt"
Set "OK_URLS=OK_URLS.txt"
Set "Not_OK_URLS=Not_OK_URLS.txt"
If Exist "%OK_URLS%" Del "%OK_URLS%"
If Exist "%Not_OK_URLS%" Del "%Not_OK_URLS%"
Call :Create_URLS_File
@for /f "delims=" %%a in ('Type "%URLs%"') do (
echo "%%a"
cscript //NoLogo CheckURL.vbs "%%a"
echo ------------------------------------
)
TimeOut /T 5 /NoBreak>nul
Start "" /MAX "%OK_URLS%"
Start "" /MAX "%Not_OK_URLS%"
Exit
::-------------------------------------------
:Create_URLS_File
(
    echo https://www.mediafire.com
    echo http://www.hyperdebrid.com
    echo http://www.fakirdebrid.net
    echo http://www.keepfiles.fr
    echo http://www.4shared.com
    echo https://1fichier.com
    echo https://www.mega.co.nz
    echo http://www.mediafire.com
    echo https://www.uploaded.net
    echo https://www.oboom.com
    echo https://www.letitbit.net
    echo https://www.keep2share.cc
    echo https://alfafile.net
    echo https://www.bigfile.to
    echo https://www.dailymotion.com
    echo https://www.datafile.com
    echo https://www.Depfile.com
    echo https://www.Dropbox.com
    echo https://www.Extmatrix.com
    echo https://www.Fboom.me
    echo https://www.Filefactory.com
    echo https://www.Filesmonster.com
    echo https://www.Fshare.vn
    echo https://www.Keep2share.com
    echo https://www.Mega.nz
    echo https://www.Rapidgator.net
    echo https://www.Scribd.com
    echo https://www.Soundcloud.com
    echo https://www.Speedyshare.com
    echo https://www.Turbobit.net
    echo https://www.Vimeo.com
 )>"%URLS%"
 ::-------------------------------------------

Now what you have to do, is just to execute the batch file  ;D
Title: Re: I need to create a batch file, which should give me output and send emails
Post by: Santosh on April 15, 2020, 06:22:27 AM
I have just pasted the code in notepad and saved them.
Tried to execute but it is giving me error as cannot find Ok_URLs.txt file. So I didnt understood that. Can you please explain.

Because I have one URLs.txt file with the required URLs in that already.
And one more thing, we just need to execute the batch file right.
Title: Re: I need to create a batch file, which should give me output and send emails
Post by: Santosh on April 15, 2020, 10:17:56 PM
I am getting below error:
------------------------------------
"https://www.Turbobit.net"
Input Error: Can not find script file "C:\WINDOWS\system32\CheckURL.vbs".
------------------------------------
"https://www.Vimeo.com"
Input Error: Can not find script file "C:\WINDOWS\system32\CheckURL.vbs".
------------------------------------

And along with this it is giving me error as Ok_URL.txt and NotOk_URL.txt not found. Please check the attachment of error.
Title: Re: I need to create a batch file, which should give me output and send emails
Post by: Santosh on April 16, 2020, 12:54:16 AM
Ok Now I am able to successfully execute the script. But after the successfull execution it is just creating text files for "Ok URLs and NotOk URLs".
Instead it should send message as a mail notification only if the URL is down with the error output.
Title: Re: I need to create a batch file, which should give me output and send emails
Post by: Santosh on April 16, 2020, 04:04:34 AM
Your response will be appreciated. As your code works fine, small change is required that instead of saving the output to a file, it should send a mail notifiaction using BLAT with the error logs. I have Blat configuration ready only thing is I am confused where I can include in the above code to get the updates only when server is down and not available.
Title: Re: I need to create a batch file, which should give me output and send emails
Post by: Hackoo on April 16, 2020, 09:18:53 AM
Your response will be appreciated. As your code works fine, small change is required that instead of saving the output to a file, it should send a mail notifiaction using BLAT with the error logs. I have Blat configuration ready only thing is I am confused where I can include in the above code to get the updates only when server is down and not available.
Just be patient i will post you another solution for testing  ;) :)
@+
Title: Re: I need to create a batch file, which should give me output and send emails
Post by: Hackoo on April 16, 2020, 01:41:24 PM
Here is an example that i tested on my side. ( I just replied to you here on stackoverflow (https://stackoverflow.com/questions/61204477/output-to-send-email-notification-if-the-url-is-not-live?answertab=active#tab-top) )
You should just change the variable SenderRecipient and SMTP_Server
Code: [Select]
@echo off
Title Send email notification if the URL is not live with BLAT
Color 0A
set "URLS=%~dp0URLS.txt"

If Not Exist "%URLS%" (
Color 0C & echo(
echo You should provide "%URLS%" with this batch file "%~nx0"
TimeOut /T 10 /NoBreak>nul
Exit
)

Set "Not_OK_URLS=%~dp0Not_OK_URLS.txt"
Set "BLAT=%~dp0blat.exe"
Set "LOG_BLAT=%~dp0LogBlat.txt"

If Exist "%Not_OK_URLS%" Del "%Not_OK_URLS%"
If Exist "%LOG_BLAT%" Del "%LOG_BLAT%"

Setlocal EnableDelayedExpansion
@for /f "delims=" %%a in ('Type "%URLS%"') do (
Call :StringFormat "%%a" URL
(ping -n 1 "!URL!" | findstr /r /c:"[0-9] *ms">nul) && (echo %%a is OnLine ==^> Success) || (echo %%a is Dead  ==^> FAILURE)>>"%Not_OK_URLS%"
)
If Exist "%Not_OK_URLS%" Call :Mail
REM If Exist "%LOG_BLAT%" Start "" "%LOG_BLAT%"
Exit
::*************************************************************************************
:StringFormat <URL>

    echo Function StringReplace(Str^)
    echo    Str = Replace(Str,"http://",""^)
    echo    Str = Replace(Str,"https://",""^)
    echo    StringReplace = str
    echo End Function
    echo wscript.echo StringReplace("%~1"^)
)>"%tmp%\%~n0.vbs"
for /f "delims=" %%a in ('Cscript /nologo "%tmp%\%~n0.vbs"') do ( set "%2=%%a" )
If Exist "%tmp%\%~n0.vbs" Del "%tmp%\%~n0.vbs"
exit /b
::*************************************************************************************
:Mail
cls
Set Sender=-f [email protected]
set Recipient=-to [email protected]
set Subject=-s "Multi Ping URLS Tester and sending mail with BLAT"
set SMTP_Server=-server smtp.changeme.com
Set body=-body "App is Down, please find the attachment for the error logs"
set Message=-bodyF "%Not_OK_URLS%"
set Attachment=-attach "%Not_OK_URLS%"
set Log=-log "%LOG_BLAT%"
set Debug=-debug
echo.
echo             Please Wait a While ... Sending Mail is in progress ......
%BLAT% %Sender% %Recipient% %Subject% %Message% %SMTP_Server% %Attachment% %Log% %Debug%>nul
Exit /B
::*************************************************************************************
Title: Re: I need to create a batch file, which should give me output and send emails
Post by: Santosh on April 17, 2020, 12:44:53 AM
I have checked the above code by executing it, it is executing successfully but I am not getting any mail notification for the failure or DOWN URLs.
And please try to use "CURL -i URL" so that will get the error response and store it in file and send as attachment in a mail.

Now it is creating NotOKURLs.txt file for the URL which is not live, but along with that if we use attachment as error logs from CURL command.

Hoping for your quick response, please check why it is not sending the mails, I have set the smtp,sender and recipient properly.
Title: Re: I need to create a batch file, which should give me output and send emails
Post by: Hackoo on April 17, 2020, 02:16:04 AM
I have checked the above code by executing it, it is executing successfully but I am not getting any mail notification for the failure or DOWN URLs.
And please try to use "CURL -i URL" so that will get the error response and store it in file and send as attachment in a mail.

Now it is creating NotOKURLs.txt file for the URL which is not live, but along with that if we use attachment as error logs from CURL command.

Hoping for your quick response, please check why it is not sending the mails, I have set the smtp,sender and recipient properly.
Can you PM me the LogBlat.txt created by this script in order to tell you what's going wrong on your side ?
Title: Re: I need to create a batch file, which should give me output and send emails
Post by: Santosh on April 17, 2020, 02:27:07 AM
I couldnt find the LogBlat.txt file in the respective path. I think it is not creating that.
And if possible could you please explain the code, coz I have some doubts so.

Thanks in advance!!!
Title: Re: I need to create a batch file, which should give me output and send emails
Post by: Santosh on April 17, 2020, 09:15:26 PM
Hoping for a quick response as it is like a headache now for me :(
Title: Re: I need to create a batch file, which should give me output and send emails
Post by: Hackoo on April 18, 2020, 02:32:00 PM
Hi  ;)
Give a try for this batch file and modify to your settings !
Remark : You should modify your smtp of your provider and don't use the smtp of yahoo because it won't let you relay to your mail !
Code: [Select]
@echo off
Title Check URLS & Color 0A
Set "URL=%~dp0URL.txt"
If Not Exist "%URL%" Call :Create_URL_File

Set "Not_OK_URL=%~dp0Not_OK_URL.txt"
If Exist "%Not_OK_URL%" Del "%Not_OK_URL%"

:Check_URL
@for /F "usebackq delims=" %%u in ("%URL%") do (
curl -I -s "%%u" | find /I "200">nul 2>&1 && (echo "%%u" ==^> is OK) || (echo "%%u" ==^> Not OK)>>"%Not_OK_URL%"
)
If Exist "%Not_OK_URL%" Call :Send_Mail_BLAT
Echo( Done
Timeout /T 3 /NoBreak>nul
exit
::--------------------------------------------------------------
:Create_URL_File
(
echo http://dummy.restapiexample.com/api/v1/employees
echo http://dummy.restapiexample.com/api/v1/employee/1
echo http://dummy.restapiexample.com/api/v1/update/21
echo https://www.mediafire.com
echo https://www.Vimeo.com
echo https://vimeo.com/fr/
echo https://www.yahoo.com
echo https://www.google.com
)>"%URL%"
Exit /b
::--------------------------------------------------------------
:Send_Mail_BLAT
cls
Set BLAT=%~dp0blat.exe
set LOG_BLAT=%~dp0LOG_BLAT.txt
Set Sender=-f %username%@hackoo.com
set Recipient=-to [email protected]
set Subject=-s "Multi Ping URLS Tester and sending mail with BLAT"
set SMTP_Server=-server smtp.provider.com
Set body=-body "App is Down, please find the attachment for the error logs"
set Message=-bodyF "%Not_OK_URL%"
set Attachment=-attach "%Not_OK_URL%"
set Log=-log "%LOG_BLAT%"
set Debug=-debug
echo.
echo             Please Wait a While ... Sending Mail is in progress ......
%BLAT% %Sender% %Recipient% %Subject% %Message% %SMTP_Server% %Attachment% %Log% %Debug%>nul
Exit /B
::--------------------------------------------------------------
Title: Re: I need to create a batch file, which should give me output and send emails
Post by: Santosh on April 20, 2020, 07:03:13 AM
Thanks for the batch file, it is working as expected. But it is just giving me the mail notification as (" URL " is not ok)
My requirement is when I do
Code: [Select]
CURL -i "URL" It  will give me some output and that output I want to print it in mail for the particular URL is DOWN with the error logs

Your quick response will be appreciated sir :)
Title: Re: I need to create a batch file, which should give me output and send emails
Post by: Hackoo on April 20, 2020, 07:18:41 AM
Thanks for the batch file, it is working as expected. But it is just giving me the mail notification as (" URL " is not ok)
My requirement is when I do
Code: [Select]
CURL -i "URL" It  will give me some output and that output I want to print it in mail for the particular URL is DOWN with the error logs

Try to modify the script at this line :
Code: [Select]
curl -I -s "%%u" | find /I "200">nul 2>&1 && (echo "%%u" ==^> is OK) || (echo "%%u" ==^> Not OK)>>"%Not_OK_URL%"by this one :
Code: [Select]
curl -I -s "%%u" | find /I "200">nul 2>&1 && (echo "%%u" ==^> is OK) || (curl -i "%%u")>>"%Not_OK_URL%"
Title: Re: I need to create a batch file, which should give me output and send emails
Post by: Santosh on April 20, 2020, 07:35:15 AM
Thanks alot sir :) It is working fine. But it is just giving me error logs and unable to find which URL/API is down.
So it will be good while printing error logs before print the URL/API name and respective of the URL/API name and below error logs of that. Then it will be easy to identify which one is down.
Title: Re: I need to create a batch file, which should give me output and send emails
Post by: Hackoo on April 20, 2020, 07:44:52 AM
Thanks alot sir :) It is working fine. But it is just giving me error logs and unable to find which URL/API is down.
So it will be good while printing error logs before print the URL/API name and respective of the URL/API name and below error logs of that. Then it will be easy to identify which one is down.
Did you mean that you want to get as output like that ?
Quote
"http://dummy.restapiexample.com/api/v1/employee/1"
HTTP/1.1 400 Bad Request
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: Content-Type, X-Requested-With, X-authentication, X-client
Cache-Control: no-cache
Content-Type: application/json;charset=utf-8
Date: Mon, 20 Apr 2020 13:41:55 GMT
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Host-Header: c2hhcmVkLmJsdWVob3N0LmNvbQ==
Pragma: no-cache
Referrer-Policy:
Response: 400
Server: nginx/1.16.0
Set-Cookie: PHPSESSID=530b13c852bb686a0b664c3b6f75b527; path=/
Set-Cookie: ezoadgid_133674=-1; Path=/; Domain=restapiexample.com; Expires=Mon, 20 Apr 2020 14:11:54 UTC
Set-Cookie: ezoref_133674=; Path=/; Domain=restapiexample.com; Expires=Mon, 20 Apr 2020 15:41:54 UTC
Set-Cookie: ezoab_133674=mod68; Path=/; Domain=restapiexample.com; Expires=Mon, 20 Apr 2020 15:41:54 UTC
Set-Cookie: active_template::133674=pub_site.1587390114; Path=/; Domain=restapiexample.com; Expires=Wed, 22 Apr 2020 13:41:54 UTC
Vary: Accept-Encoding
Vary: Accept-Encoding,X-APP-JSON
X-Ezoic-Cdn: Miss
X-Middleton-Response: 400
X-Sol: pub_site

"http://dummy.restapiexample.com/api/v1/update/21"
HTTP/1.1 405 Method Not Allowed
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: Content-Type, X-Requested-With, X-authentication, X-client
Allow: PUT
Cache-Control: no-cache
Content-Type: text/html;charset=UTF-8
Date: Mon, 20 Apr 2020 13:41:57 GMT
Expires: Sun, 19 Apr 2020 13:41:57 GMT
Host-Header: c2hhcmVkLmJsdWVob3N0LmNvbQ==
Pagespeed: off
Pragma: no-cache
Referrer-Policy:
Response: 405
Server: nginx/1.16.0
Set-Cookie: PHPSESSID=37a6badd8b6e46a34353cedc95d7281e; path=/
Set-Cookie: ezoadgid_133674=-1; Path=/; Domain=restapiexample.com; Expires=Mon, 20 Apr 2020 14:11:57 UTC
Set-Cookie: ezoref_133674=; Path=/; Domain=restapiexample.com; Expires=Mon, 20 Apr 2020 15:41:57 UTC
Set-Cookie: ezoab_133674=mod28; Path=/; Domain=restapiexample.com; Expires=Mon, 20 Apr 2020 15:41:57 UTC
Set-Cookie: active_template::133674=pub_site.1587390117; Path=/; Domain=restapiexample.com; Expires=Wed, 22 Apr 2020 13:41:57 UTC
Set-Cookie: ezCMPCCS=true; Path=/; Domain=restapiexample.com; Expires=Tue, 20 Apr 2021 13:41:57 GMT
Vary: Accept-Encoding
Vary: Accept-Encoding,X-APP-JSON
X-Ezoic-Cdn: Miss
X-Middleton-Response: 405
X-Sol: pub_site

"https://www.Vimeo.com"
HTTP/1.1 301 Moved Permanently
Connection: keep-alive
Content-Length: 226
Server: nginx
Content-Type: text/html; charset=iso-8859-1
Location: https://vimeo.com/
Expires: Mon, 15 Apr 2030 19:24:58 GMT
Via: 1.1 varnish
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
X-Varnish-Cache: 1
X-VServer: infra-webproxy-a-16
X-Vimeo-DC: ge
Via: 1.1 varnish
Accept-Ranges: bytes
Date: Mon, 20 Apr 2020 13:42:01 GMT
Via: 1.1 varnish
Age: 0
X-Served-By: cache-bwi5139-BWI, cache-cdg20724-CDG
X-Cache: MISS, MISS
X-Cache-Hits: 0, 0
X-Timer: S1587390122.826389,VS0,VE88
Vary: Accept-Encoding
Title: Re: I need to create a batch file, which should give me output and send emails
Post by: Santosh on April 20, 2020, 07:47:30 AM
Yes absolutely !!!
Title: Re: I need to create a batch file, which should give me output and send emails
Post by: Hackoo on April 20, 2020, 07:55:03 AM
Yes absolutely !!!
Try llike that instead :
Code: [Select]
curl -I -s "%%u" | find /I "200">nul 2>&1 && (echo "%%u" ==^> is OK) || (echo "%%u" & curl -I "%%u")>>"%Not_OK_URL%"
Title: Re: I need to create a batch file, which should give me output and send emails
Post by: Santosh on April 20, 2020, 08:06:32 AM
Thanks alot. But the URL for the first error log it is coming properly on top. And from the second URL, it is just appending from the last line of error log from the first error log. So it is not coming as standard formatting. It should come properly like :

URL name:
Error log
One line gap
Second URL name:
Error log
Title: Re: I need to create a batch file, which should give me output and send emails
Post by: Santosh on April 21, 2020, 12:24:47 AM
Your quick response will be added more value. It is almost done just to add my previous comment changes.
Thanks in advance!!!
Title: Re: I need to create a batch file, which should give me output and send emails
Post by: Hackoo on April 21, 2020, 01:09:11 AM
Your quick response will be added more value. It is almost done just to add my previous comment changes.
Thanks in advance!!!
Show me your code and what did you get as ErrorLog and what did you exactly expect to be ?
EDIT : Try like this :
Code: [Select]
:Check_URL
@for /F "usebackq delims=" %%u in ("%URL%") do (
curl -I -s "%%u" | find /I "200">nul 2>&1 && (
echo "%%u" ==^> is OK
) || (
echo ---------------------------------------------------
echo "%%u"
echo ---------------------------------------------------
curl -I -s "%%u"
)>>"%Not_OK_URL%"
)
Title: Re: I need to create a batch file, which should give me output and send emails
Post by: Santosh on April 21, 2020, 01:26:56 AM
This is my code:
Code: [Select]
:Check_URL
@for /F "usebackq delims=" %%u in ("%URL%") do (
 curl -I -s "%%u" | find /I "200">nul 2>&1 && (echo "%%u" ==^> is OK) || (echo "%%u" & curl -i "%%u")>>"%Not_OK_URL%"
)
If Exist "%Not_OK_URL%" blat -subject "APPLICATIONs DOWN STATUS" -body "app status is down, please check the attachment for the Application DOWN error logs" -attach C:\Not_OK_URL.txt  %Log% -to [email protected]

Error logs:
Code: [Select]
"http://dummy.restapiexample.com/api/v1/employee/1"
HTTP/1.1 400 Bad Request
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: Content-Type, X-Requested-With, X-authentication, X-client
Cache-Control: no-cache
Content-Type: application/json;charset=utf-8
Date: Mon, 20 Apr 2020 13:41:55 GMT
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Host-Header: c2hhcmVkLmJsdWVob3N0LmNvbQ==
Pragma: no-cache
Referrer-Policy:
Response: 400
Server: nginx/1.16.0
Set-Cookie: PHPSESSID=530b13c852bb686a0b664c3b6f75b527; path=/
Set-Cookie: ezoadgid_133674=-1; Path=/; Domain=restapiexample.com; Expires=Mon, 20 Apr 2020 14:11:54 UTC
Set-Cookie: ezoref_133674=; Path=/; Domain=restapiexample.com; Expires=Mon, 20 Apr 2020 15:41:54 UTC
Set-Cookie: ezoab_133674=mod68; Path=/; Domain=restapiexample.com; Expires=Mon, 20 Apr 2020 15:41:54 UTC
Set-Cookie: active_template::133674=pub_site.1587390114; Path=/; Domain=restapiexample.com; Expires=Wed, 22 Apr 2020 13:41:54 UTC
Vary: Accept-Encoding
Vary: Accept-Encoding,X-APP-JSON
X-Ezoic-Cdn: Miss
X-Middleton-Response: 400
X-Sol: pub_site"http://dummy.restapiexample.com/api/v1/update/21"
HTTP/1.1 405 Method Not Allowed
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: Content-Type, X-Requested-With, X-authentication, X-client
Allow: PUT
Cache-Control: no-cache
Content-Type: text/html;charset=UTF-8
Date: Mon, 20 Apr 2020 13:41:57 GMT
Expires: Sun, 19 Apr 2020 13:41:57 GMT
Host-Header: c2hhcmVkLmJsdWVob3N0LmNvbQ==
Pagespeed: off

So in the error logs, the second URL is appending from the last line of first error log

Instead it should be:
URL name
Error log
One line gap
Second URL name
Error log


Thanks in advance!!!
Title: Re: I need to create a batch file, which should give me output and send emails
Post by: Hackoo on April 21, 2020, 01:33:02 AM
When i try like this :
Code: [Select]
:Check_URL
@for /F "usebackq delims=" %%u in ("%URL%") do (
curl -I -s "%%u" | find /I "200">nul 2>&1 && (
echo "%%u" ==^> is OK
) || (
echo ---------------------------------------------------
echo "%%u"
echo ---------------------------------------------------
curl -I -s "%%u"
)>>"%Not_OK_URL%"
)
I got something like that :
Code: [Select]
---------------------------------------------------
"http://dummy.restapiexample.com/api/v1/employee/1"
---------------------------------------------------
HTTP/1.1 400 Bad Request
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: Content-Type, X-Requested-With, X-authentication, X-client
Cache-Control: no-cache
Content-Type: application/json;charset=utf-8
Date: Tue, 21 Apr 2020 07:22:42 GMT
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Host-Header: c2hhcmVkLmJsdWVob3N0LmNvbQ==
Pragma: no-cache
Referrer-Policy:
Response: 400
Server: nginx/1.16.0
Set-Cookie: PHPSESSID=0fccc982efcf0603ff3db3828c95d3a6; path=/
Set-Cookie: ezoadgid_133674=-1; Path=/; Domain=restapiexample.com; Expires=Tue, 21 Apr 2020 07:52:41 UTC
Set-Cookie: ezoref_133674=; Path=/; Domain=restapiexample.com; Expires=Tue, 21 Apr 2020 09:22:41 UTC
Set-Cookie: ezoab_133674=mod62-c; Path=/; Domain=restapiexample.com; Expires=Tue, 21 Apr 2020 09:22:41 UTC
Set-Cookie: active_template::133674=pub_site.1587453761; Path=/; Domain=restapiexample.com; Expires=Thu, 23 Apr 2020 07:22:41 UTC
Vary: Accept-Encoding
Vary: Accept-Encoding,X-APP-JSON
X-Ezoic-Cdn: Miss
X-Middleton-Response: 400
X-Sol: pub_site

---------------------------------------------------
"http://dummy.restapiexample.com/api/v1/update/21"
---------------------------------------------------
HTTP/1.1 405 Method Not Allowed
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: Content-Type, X-Requested-With, X-authentication, X-client
Allow: PUT
Cache-Control: no-cache
Content-Type: text/html;charset=UTF-8
Date: Tue, 21 Apr 2020 07:22:44 GMT
Expires: Mon, 20 Apr 2020 07:22:44 GMT
Host-Header: c2hhcmVkLmJsdWVob3N0LmNvbQ==
Pagespeed: off
Pragma: no-cache
Referrer-Policy:
Response: 405
Server: nginx/1.16.0
Set-Cookie: PHPSESSID=c521f5c48c7cce039692a0b8452b2bf5; path=/
Set-Cookie: ezoadgid_133674=-1; Path=/; Domain=restapiexample.com; Expires=Tue, 21 Apr 2020 07:52:43 UTC
Set-Cookie: ezoref_133674=; Path=/; Domain=restapiexample.com; Expires=Tue, 21 Apr 2020 09:22:43 UTC
Set-Cookie: ezoab_133674=mod54-c; Path=/; Domain=restapiexample.com; Expires=Tue, 21 Apr 2020 09:22:43 UTC
Set-Cookie: active_template::133674=pub_site.1587453763; Path=/; Domain=restapiexample.com; Expires=Thu, 23 Apr 2020 07:22:43 UTC
Set-Cookie: ezCMPCCS=true; Path=/; Domain=restapiexample.com; Expires=Wed, 21 Apr 2021 07:22:44 GMT
Vary: Accept-Encoding
Vary: Accept-Encoding,X-APP-JSON
X-Ezoic-Cdn: Miss
X-Middleton-Response: 405
X-Sol: pub_site

---------------------------------------------------
"https://www.Vimeo.com"
---------------------------------------------------
HTTP/1.1 301 Moved Permanently
Connection: keep-alive
Content-Length: 226
Server: nginx
Content-Type: text/html; charset=iso-8859-1
Location: https://vimeo.com/
Expires: Mon, 15 Apr 2030 19:24:58 GMT
Via: 1.1 varnish
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
X-Varnish-Cache: 1
X-VServer: infra-webproxy-a-16
X-Vimeo-DC: ge
Via: 1.1 varnish
Accept-Ranges: bytes
Date: Tue, 21 Apr 2020 07:22:47 GMT
Via: 1.1 varnish
Age: 0
X-Served-By: cache-bwi5151-BWI, cache-cdg20749-CDG
X-Cache: MISS, MISS
X-Cache-Hits: 0, 0
X-Timer: S1587453767.126375,VS0,VE84
Vary: Accept-Encoding