Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 31 Oct 2013 21:56:01 -0500
From:      Martin McCormick <martin@dc.cis.okstate.edu>
To:        "freebsd-questions@freebsd.org" <freebsd-questions@freebsd.org>
Subject:   Inputs and outputs in the right order
Message-ID:  <201311010256.rA12u1jx009134@x.it.okstate.edu>

next in thread | raw e-mail | index | archive | help
	One of the beauties of unix is the ability to open a
shell such as omshell or even the Bourne or C shells and feed
commands to the shell from a script. One can capture the output
of the shell to generate log entries or status messages for the
benefit of the operator of the application.

	If you do that, however, there is an interesting
problem. If one was to manually enter commands to the shell, the
output looks like:

some_command
shell_output for one or more lines and then
some_other_command
shell_response.

	When an automated script is entering commands, what
appears to happen is that standard input sucks in gobs of lines
as fast as it can and then the shell runs them sequentially if
possible so it all happens very fast on a modern system.

	The problem is that if one is capturing the session, the
shell usually doesn't echo each command as executed. If you use
a special application such as script, one sees all the commands
fed in as a block followed by the results of the sequential
execution of the block of commands coming out as a block. It is
sometimes hard to tell exactly what happened to make the job
fail because one does not have the command string followed by
the results.

	I know that expect does a great job of logging a session
but I am wondering if there is an easier way to get the shell
input echoed interwoven with all the output. In shorter words,
what is the easiest way to produce a session log that reads like
what actually happened when it happened?

Thanks for any and all constructive ideas.

Martin McCormick



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201311010256.rA12u1jx009134>