Mailing List Archive

non-tty use of "console" client.
I've recently been trying to solve a dilema with conserver, my terminal
server, my BEST UPS's, Cricket, and nut-ups.

Ideally I'd like conserver to be in control of the UPS consoles via the
terminal server, but in order to use both Cricket and nut-ups with them
I need some way to send periodic commands to the UPS from cron.
(nut-ups and cricket can both be taught to watch the log file)

I thought, oh, this should be easy, I'll just "echo f | console -f ups"
using a user-ID that doesn't require a password and be done with it.

Unfortunately when I tried that the conserver daemon came crashing down
claiming to have suffered an unexpected SIGPIPE. This was not a
pleasant experience since it was my main production conserver! :-(

I took a brief look through the code to try and understand the signal
handling mechanisms, but quickly realised that I'd need a lot more time
to understand what was going on, let alone how to fix the problem.

I suppose I could try to write a custom "console" client too, but that
also seemed like it would take some time I don't seem to have.

Ideally I'd like to also have "console" show the resulting output on
stdout, say up to the next prompt (it would send a <CR> or whatever is
specified to determine what the prompt string is), or for some specified
number of lines, or up to the end of some specified regular expression,
etc.

Has anyone else thought of this, or have any suggestions?

--
Greg A. Woods

+1 416 218-0098; <gwoods@acm.org>; <g.a.woods@ieee.org>; <woods@robohack.ca>
Planix, Inc. <woods@planix.com>; VE3TCP; Secrets of the Weird <woods@weird.com>
non-tty use of "console" client. [ In reply to ]
On Tue, Jan 15, 2002 at 01:55:52PM -0500, Greg A. Woods wrote:
> I thought, oh, this should be easy, I'll just "echo f | console -f ups"
> using a user-ID that doesn't require a password and be done with it.
>
> Unfortunately when I tried that the conserver daemon came crashing down
> claiming to have suffered an unexpected SIGPIPE. This was not a
> pleasant experience since it was my main production conserver! :-(

hmm...i just tried that myself (well, 'echo ls | console -f foo4') and
it didn't crash (using conserver-7.1.4-beta). the client didn't see
the output of ls, but the logfile has it. what version of conserver
and what type of host are you using (solaris 7, myself)?

> Ideally I'd like to also have "console" show the resulting output on
> stdout, say up to the next prompt (it would send a <CR> or whatever is
> specified to determine what the prompt string is), or for some specified
> number of lines, or up to the end of some specified regular expression,
> etc.
>
> Has anyone else thought of this, or have any suggestions?

well, assuming we can get the thing from crashing with a SIGPIPE, you
could do something like:

(echo 'ls'; sleep 5) | console -f ups

as long as you don't close stdin of the client you'll be able to see
the output (worked for me, anyway). using this as a base, you could
write a wrapper that fed data to the console client and read it's
output. as long as you kept the feed open and only closed it once you
saw the regexp or CR or whatever coming out the other end, you should
be able to do just about anything. heck, you could even do a whole
expect-like thing and feed more commands based on the output and such.
in theory, the perl IPC::Open2 module should provide at least one
method of doing this (or the Expect module, or...).

Bryan