Inputs and outputs in the right order

Martin McCormick martin at
Fri Nov 1 16:36:26 UTC 2013

CyberLeo Kitsana writes:
> In bourne-compatible shells (/bin/sh, bash) run 'set -x' or pass the -x
> flag during invocation to turn on debug output. The shell will print out
> each command it is about to invoke.
> The output requires some interpretation, as it can get confusing in the
> presence of variable expansion, pipelines, and subshells; but it should
> be adequate for a simple list of commands.

Thanks for a great suggestion. This is a perl script which runs
omshell commands to adjust the data base on a pair of DHCP
servers. omshell has no echo facility or this whole exercise
would have most likely just worked. As it is, it does a fine job
of modifying the DHCP servers but the output is the sort that
would confuse and frustrate folks who aren't used to seeing hex
representations of IP addresses and outputs that repeat existing
data plus add the newest change so it's better to evaluate the
results of what just happened and tell the caller, "Added to dh1" or "failed to remove from
dh1." That is easy to do in a script when you can corral all
the pieces of the puzzle in one list or array. When everything
works, we do actually get enough echoed information to do this
but if someone is trying to delete a system that doesn't exist,
we only end up with a notice of an object not found and no name
or identifying information that a caller could use to know what
wasn't found.

	The person suggesting the use of the $| variable in perl
is on to the right idea if I can ever get a log file containing
the commands to omshell plus omshells output after each command.

	As with all such problems, one learns a lot. I was
unaware of $| in perl and how it disables buffering if set to
anything other than 0.

	I will also ask the dhcp discussion group if anyone has
tricked omshell in to echoing. You can't give it a flag to do so
or tell it to echo. We are in the realm of tricks to essentially
get something to do what it is not designed to do. Most of us
tinkerers don't mind that to an extent, but I never sease to be
amazed at what ordinary tasks just refuse to work at times.

Thank you, all.

Martin McCormick WB5AGZ  Stillwater, OK 
Systems Engineer
OSU Information Technology Department Telecommunications Services Group

More information about the freebsd-questions mailing list