Hi guys,
I have searched forum and found a few things I may be able to work with but I wondered if maybe there is something I have missed:
I have to run a script that will be connected to an external server. Occasionally the server connection will die and of course the script then continues to run as it is not aware that the server has connection has died.
I think the server when active can be pinged.
Can anyone suggest a way to check for active server before continuing the script etc?
I hope this makes sense.
Checking for connection to a server?
Moderators: JRL, Dorian (MJT support)
- Phil Pendlebury
- Automation Wizard
- Posts: 543
- Joined: Tue Jan 16, 2007 9:00 am
- Contact:
Checking for connection to a server?
Phil Pendlebury - Linktree
Re: Checking for connection to a server?
Hi Phil,
You CAN do something as simple as a ping to tell you whether or not the server is connected to the network, but that may not give you enough information. A specific service that your script needs to have running on the server could stop so your script fails but the server still pings. I've always found it more prudent to test the result of whatever action I've taken or plan to take. If you do a HTTPRequest> does the result come back empty? Is there a "404 Error connecting to host" in the result? If you're doing a DBQuery> did number of rows come back as "0" or does your DBConnect> result variable contain the text "Server not found"?
Hope this helps,
Dick
You CAN do something as simple as a ping to tell you whether or not the server is connected to the network, but that may not give you enough information. A specific service that your script needs to have running on the server could stop so your script fails but the server still pings. I've always found it more prudent to test the result of whatever action I've taken or plan to take. If you do a HTTPRequest> does the result come back empty? Is there a "404 Error connecting to host" in the result? If you're doing a DBQuery> did number of rows come back as "0" or does your DBConnect> result variable contain the text "Server not found"?
Hope this helps,
Dick
- Phil Pendlebury
- Automation Wizard
- Posts: 543
- Joined: Tue Jan 16, 2007 9:00 am
- Contact:
Re: Checking for connection to a server?
Hi guys,
I thought I would make a brief (albeit obvious) post as to how this was solved.
The server could not be reached via any scripting calls, as it is severely restricted for security.
But there is a second data entry screen that is accessed using function keys (sometimes my script calls this).
What I did not realise was that the second screen is not accessible when the server dies. So I simply took a screen shot of the second screen, and get the script to attempt to bring up the screen and wait for the image, it takes about quarter of a second to find the image before entering each record.
If the screen check times out - the server is dead (or there is some other reason the screen cannot be accessed - ie an unknown error message). A message is written to the log and the script will quit, allowing the user to continue later where they left off.
So a simple solution really. I had thought about using something similar earlier, but the thing was I had no idea that the second screen was not accessible when the server dies and the main screen itself does not change in any way. There were no external signs that the server had died.

I thought I would make a brief (albeit obvious) post as to how this was solved.
The server could not be reached via any scripting calls, as it is severely restricted for security.
But there is a second data entry screen that is accessed using function keys (sometimes my script calls this).
What I did not realise was that the second screen is not accessible when the server dies. So I simply took a screen shot of the second screen, and get the script to attempt to bring up the screen and wait for the image, it takes about quarter of a second to find the image before entering each record.
If the screen check times out - the server is dead (or there is some other reason the screen cannot be accessed - ie an unknown error message). A message is written to the log and the script will quit, allowing the user to continue later where they left off.
So a simple solution really. I had thought about using something similar earlier, but the thing was I had no idea that the second screen was not accessible when the server dies and the main screen itself does not change in any way. There were no external signs that the server had died.

Phil Pendlebury - Linktree