Advertisement
hamacker

Teste de conexão com o servidor/database Firebird

Mar 1st, 2018
279
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 2.07 KB | None | 0 0
  1. @echo off
  2. rem Autor: Gladiston (hamacker) Santana sirhamacker em gmail.com
  3. rem Arquivo: fb_test_conn.cmd
  4. rem Objetivo: Testar conectividade com servidores firebird
  5. rem Se o resultdo da execucao do script nao exibir informacoes da conexao, entao
  6. rem   o script falhou.
  7. rem PS: O formato deste arquivo deve ser ANSI Windows (CR/LF) caso contrario nao funcionará
  8. rem   no ambiente de terminal do Windows.
  9. set fb3_connect="localhost:c:\caminho\para\o\database.fdb"
  10. set ISC_USER=SYSDBA
  11. set ISC_PASSWORD=masterkey
  12. set fb3_script=%temp%\temp_script_isql.$$$
  13. set fb3_isql="isql.exe"
  14. if exist "%ProgramFiles%\Firebird\Firebird_3_0\isql.exe" set fb3_isql=%ProgramFiles%\Firebird\Firebird_3_0\isql.exe
  15. if exist "%ProgramFiles(x86)%\Firebird\Firebird_3_0\isql.exe" set fb3_isql=%ProgramFiles(x86)%\Firebird\Firebird_3_0\isql.exe
  16. if not exist "%fb3_isql%" goto notfound
  17. rem ===
  18. rem === Nao altere mais nada daqui para baixo
  19. rem ===
  20. rem === criando o script ====
  21. echo -- %fb3_script% ; >"%fb3_script%"
  22. echo CONNECT %fb3_connect%;>>"%fb3_script%"
  23. echo set list on; >>"%fb3_script%"
  24. echo select * from mon$attachments where mon$attachment_id = current_connection; >>"%fb3_script%"
  25. echo show database; >>"%fb3_script%"
  26. echo quit; >>"%fb3_script%"
  27. rem === executando o script ====
  28. cls
  29. echo TESTE DE CONEXAO COM BASE DE DADOS
  30. echo ISQL: %fb3_isql%
  31. echo Temporary script: %fb3_script%
  32. echo Connect: %fb3_connect%
  33. echo UserName: %ISC_USER%
  34. echo Password: *****
  35. echo Cmd: "%fb3_isql%" -z -q -i "%fb3_script%"
  36. "%fb3_isql%" -z -q -i "%fb3_script%"
  37. set os_result=%ERRORLEVEL%
  38. set os_info=Successful execution
  39. if %os_result% LSS 0   set os_info=statement did not execute
  40. if %os_result% GTR 1   set os_info=System warning or information message
  41. if %os_result% GEQ 100 set os_info=No qualifying rows found, or end of current active set of rows reached
  42. echo ISQL Result: %os_info% (%os_result%)
  43. goto fim
  44. :notfound
  45. echo ajuste neste .cmd a variavel *fb3_isql* para que seja possivel encontrar o utilitario isql.exe do firebird.
  46. goto fim
  47. :fim
  48. if exist "%fb3_script%" del /q /f "%fb3_script%"
  49. pause
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement