Back
Can anyone tell me how to efficiently check if a port 445 is open/listening on a server with bash script?
Below is the code to test for listening on a local server in a script:
exec 6<>/dev/tcp/127.0.0.1/445 || echo "No one is listening!"exec 6>&- # close output connectionexec 6<&- # close input connection
exec 6<>/dev/tcp/127.0.0.1/445 || echo "No one is listening!"
exec 6>&- # close output connection
exec 6<&- # close input connection
Interested in Linux? Check out this Linux Certification by Intellipaat.
31k questions
32.8k answers
501 comments
693 users