0

we are using some 3rd party interactive command line tool, and we use tee for logging what a user did - to check later if needed...

The tool works the way it ask which action user want to perform and user selects something and continue with submenu or the action is executed.

Recently (when we needed to check such log) we realized, the user inputs are not there. Is there some alternative - how to achieve that?

When I tried to simulate the tool with:

$ cat r.sh
read -p "Enter some text: " text
echo $text

echo -n "Enter another text: "
read text2
echo $text2

I tested and this is the output

$ ./r.sh | tee run.log
Enter some text: abc
abc
Enter another text: def
def

$ cat run.log
abc
Enter another text: def

Ideally I'd like to have the same what user saw, which is not the same as you can see.

Solution:

If someone needs it I tested with

script -c ./r.sh script.log

and it worked as expected + I tested with this 3rd party tool.

3

You could use script for this; it creates a nested tty and records everything that happens in it.

If you also specify --timing=… it can even produce replayable "videos" of full-screen interactive programs (like text editors and such).


(For completeness – There is another similar tool asciinema, which is a hosted service which automatically publishes records at https://asciinema.org/. Useful for making demos and tutorials.)

  • I was mucking with script. One bit I found missing was "non interactively" ending recording it. ctrl D does it interactively - but not sure what would just end it as part of a script. – Journeyman Geek Feb 23 '17 at 12:31
  • script starts a nested shell (or another program), and the recording ends when that shell or program exits. That's all there is to it. – grawity Feb 23 '17 at 12:34
  • ah, so exit would work? – Journeyman Geek Feb 23 '17 at 12:36
  • script seems like what I wanted, will need some time to test more (I tested with what I specified and seems ok), but for now it is an option... – Betlista Feb 23 '17 at 12:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.