I'm trying to write a script to test a number of servers.
The problem is that sometimes a single server will not respond, it times out causing the script to hang.
I would therefore like some method of 'timing out' each test, i.e if the server does not respond in say 30 seconds then go on to the next server in the loop. This is using activestate 5.8.4 on a windows platform and I have tried a number of methods so far (notably alarm to trigger an interrupt) but I just can;t seem to come up with a working solution.
I've substituted 'waiting for user input' in the following example for 'testing the server', could anyone offer anyone offer up any code which would perform the following, wait for the user to enter some data, if the user does not enter anything within 10 seconds then continue the program onto the next server.
foreach $server(@servers) { my $buf=<>; # TEST SERVER }
Thanks
In reply to simple timeout by disciple01
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |