Advertisement
hackoo

Get_Status_CURL.bat

Jun 27th, 2022 (edited)
810
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 2.75 KB | None
  1. @echo off
  2. Title Get Status Codes from URL using the command line CURL
  3.  
  4. Set "ONLINE=%~dp0ONLINE.txt"
  5. If Exist "%ONLINE%" Del "%ONLINE%"
  6. Set "OFFLINE=%~dp0OFFLINE.txt"
  7. If Exist "%OFFLINE%" Del "%OFFLINE%"
  8. set /a c=0
  9.  
  10. Set URLS="https://tutanota.com" "https://www.youtube.com" "https://www.youtube.com/channel/example" ^
  11. ^ "https://www.tiktok.com" "https://www.facebook.com" "https://www.reddit.com" ^
  12. ^ "https://www.yahoo.com" "https://pastebin.com" "https://www.twitter.com" "https://twitter.com/" ^
  13. ^ "https://help4windows.com/windows_8_shell32_dll.shtml" "https://help4windows.com" "https://instant-hack.to" ^
  14. ^ "https://hackforums.net/" "https://www.ultimate-guitar.com/explore" " https://accounts.snapchat.com" ^
  15. ^ "https://stackoverflow.com" "https://superuser.com" "https://codereview.stackexchange.com" "https://security.stackexchange.com" "https://serverfault.com" ^
  16. ^ "https://ss64.com/" "https://www.dostips.com/" "https://batch.xoo.it" "https://www.developpez.com" "https://www.developpez.net" "https://www.commentcamarche.net/"
  17.  
  18. echo/
  19. SetLocal EnableDelayedExpansion
  20. @for %%a in (%URLS%) do (
  21.     set /a c+=1
  22.     Call :Get_Status "%%~a"
  23.     If [!httpCode!] EQU [200] (
  24.         Call :PSColor " !c!-[!Time!] [!httpcode!] [!Description!] [%%~a]" DarkGreen \n
  25.         echo [!Time!] [!httpcode!] [!Description!] [%%~a]>>"%ONLINE%"
  26.     ) Else (
  27.         Call :PSColor " !c!-[!Time!] [!httpcode!] [!Description!] [%%~a]" DarkRed \n
  28.         echo [!Time!] [!httpcode!] [!Description!] [%%~a]>>"%OFFLINE%"
  29.     )
  30. )
  31. EndLocal & Pause & EXIT /B
  32. REM -----------------------------------------------------------------------------------
  33. :Get_Status <url> <httpCode>
  34. @for /f "tokens=*" %%a in (
  35.     'curl -sI -o nul -w "%%{http_code}" "%~1"'
  36. ) do (
  37.     Set "httpCode=%%a"
  38.     If [!httpcode!] EQU [503] (set "Description=Service Unavailable")
  39.     If [!httpcode!] EQU [500] (set "Description=Internal Server Error")
  40.     If [!httpcode!] EQU [404] (set "Description=Not Found OFFLINE")
  41.     If [!httpcode!] EQU [403] (set "Description=Forbidden Access Denied")
  42.     If [!httpcode!] EQU [302] (set "Description=Temporary Redirect")
  43.     If [!httpcode!] EQU [301] (set "Description=Redirect and Moved Permanently")
  44.     If [!httpcode!] EQU [200] (set "Description=OK ONLINE")
  45.     If [!httpcode!] EQU [000] (set "Description=TIMEOUT Server Rejected the Request")
  46. )
  47. Exit /B
  48. REM ----------------------------------------------------------------------------------
  49. :PSColor <String> <Color> <NewLine>
  50. If /I [%3] EQU [\n] (
  51.     Powershell Write-Host "`0%~1" -ForegroundColor %2
  52. ) Else (
  53.     Powershell Write-Host "`0%~1" -ForegroundColor %2 -NoNewLine
  54. )
  55. Exit /B
  56. REM -----------------------------------------------------------------------------------
  57. REM https://www.reddit.com/r/Batch/comments/vl9drp/comment/idumo9g/?utm_source=share&utm_medium=web2x&context=3
Advertisement
RAW Paste Data Copied
Advertisement