How to use script to record actions

Sometimes when diagnosing an issue, we will ask you to show us exactly what commands you issued and what they returned. Or, you need to show us a long complicated error message. An useful tool in these cases is the scriptcommand; once you issue it, it will start a new shell and log all of your input to and all the output from the new shell. This is not that useful for programs that run in a graphical environment, but provides a fairly good log for command line processes.

For example, in the following, we log the session to the file help.script in my home directory:

ln0001:~: script help.script Script started, file is help.script ln0001:~: date Tue Oct 21 10:41:07 EDT 2021 ln0001:~: module list Currently Loaded Modulefiles: 1) dept/Glue ln0001:~: ncap2 ncap2: Command not found. ln0001:~: exit exit Script done, file is help.script ln0001:~: ln0001:~: cat help.script Script started, file is help.script ln0001:~: date Tue Oct 21 10:41:07 EDT 2021 ln0001:~: module list Currently Loaded Modulefiles: 1) dept/Glue ln0001:~: ncap2 ncap2: Command not found. ln0001:~: exit exit Script done on Tue Oct 21 10:42:51 2014 ln0001:~:

NOTE: Always remember to exit the shell started by the script command. And, as in the above example, it can be useful to print the contents of the file (e.g. with the cat command) to verify things were properly recorded.

Â