Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cmd Pinging a specific port and ip

Tags:

batch-file

cmd

I'm trying to make a simple script on cmd (bat file) to check if couple of remote servers are up and up running

i wanted to ping a specific ip and port.
when i got %ERRORLEVEL% = 1 i knew there was a problem and when i got %ERRORLEVEL% = 0 the server was ok

after some fooling around with ping command i saw that you can't ping a specific port...

then i tried using telnet on my script and telnet dosent return any value (to what i could find) if there is a successful Session or not

if anyone got any other way to check if couple servers are running for a script i would appreciate the help. Thanks

like image 573
Danbz Avatar asked Oct 31 '25 03:10

Danbz


1 Answers

if you are using windows, why don't you use PowerShell. here is a sample code to ping to a specfic port

TNC -ComputerName SQLServer01 -Port 1433
like image 126
Panna Das Avatar answered Nov 02 '25 23:11

Panna Das