Sunday, April 12, 2009

[newLISP] restart-router

The boss said I'd find Lisp addictive, and he was right.

The following is a
newLISP implementation of a project attempted in VB6. The VB6 one failed to work consistently. The newLISP one hasn't failed yet.

The situation is that our ADSL connection goes down at random times, necessitating a walk down the hall to the comms room, wherein one turns off the power to the router so that it resets. I found out during the week that if I telnet into the router, give the appropriate password and the enter 'restart', that'll restart the router. Will it reduce the need to walk to the comms room? I really don't know as, all of a sudden, the router is working fine.

Here's the code:
I really like the fourth parameter on the net-receive call; not only do I receive but I can look for something in what is received. I suppose testing for not receiving it would be good, but I'll leave that for another time.

Once the restart command is sent, there's no need to attempt a net-receive. Just close the connection. Note also the easy way of referring to and using a function in a DLL.

Using the link.lsp script (which comes in the standard newLISP install) I've been able to turn this code into a standalone EXE, and once I've established that it really does do the job, I'll install it on a couple of other machines in the office.

I suppose we actually need the exercise, but maybe we don't need the aggravation.

By the way, my last newLISP posting has generated an interesting conversation on
comp.lang.misc (also mirrored on comp.lang.lisp).

© Copyright Bruce M. Axtens, 2009

No comments: