DrBlack Posted April 19, 2010 Share Posted April 19, 2010 Hi everyone... I try to do a script that check vía telnet if a port is open, this script needs to execute every 5 minutes and if in the third attempt the script couldn't connect write a log file to capture with a monitoreing tool. Thanks in advance. Link to comment Share on other sites More sharing options...
DrBlack Posted April 19, 2010 Author Share Posted April 19, 2010 Well, I use an example in a topic and Helpfile, but the most important is to do three attemps before the ERROR writes the file. Somebody know a way to do it? Here is what I've got: $g_IP = "207.169.88.98" $g_port = "3389" ; Start The TCP Services ;============================================== TCPStartUp() ; Connect to a Listening "SOCKET" ;============================================== $log = FileOpen("c:\connect.log" , 2) $socket = TCPConnect($g_IP, $g_port) If $socket = -1 Then FileWrite($log, "ERROR") Else FileWrite($log, "OK") TCPShutdown () EndIf FileClose($log) Thanks!! Link to comment Share on other sites More sharing options...
flyingboz Posted April 19, 2010 Share Posted April 19, 2010 I ran into this a while back, and took the following approach: 1) Download PORTQRY from Microsoft. 2) Download _RunReadStd() -- lovely UDF available on the forum. 3) Use 1, 2 to write a function like: _TcpPortTest($ip,$port) essentially, you formulate your portqry request, then execute the command and parse the results. Eliminates the hassle / overhead of dealing directly w/ the sockets. Reading the help file before you post... Not only will it make you look smarter, it will make you smarter. Link to comment Share on other sites More sharing options...
DrBlack Posted April 21, 2010 Author Share Posted April 21, 2010 Thanks for the reply and the PORTQRY... The problem is that we aren't the server administrator and we are unable to install software, the only way to do the test is with a script. We are trying skip add the script Microsoft scheduler to run it. Thanks. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now