Skip to content

Use the script command to record CLI output

If you wish to show us what happens when you try to run a command/program on the Linux command-line, please use the script command. It creates a text file and records all the commands you run as well as their output.

In the following example, we create a text file called help_script.

Example

In the example below, please note that we used the script command (with the filename help_script) as the argument.

At the end, we used exit to terminate the script session.

login-1:~$ script help_script
Script started, file is help_script
login-1:~$ date
Tue Dec 17 22:20:11 EST 2024
login-1:~$ module load openmpi
Loading openmpi/gcc/11.3.0/zen2/4.1.5
  Loading requirement: gcc/11.3.0
login-1:~$ module list
Currently Loaded Modulefiles:
 1) hpcc/zaratan(default)   2) gcc/11.3.0   3) openmpi/gcc/11.3.0/zen2/4.1.5  
login-1:~$ ncap23
bash: ncap23: command not found
login-1:~$ exit
exit
Script done, file is help_script
login-1:~$

Before you tell the HPC systems staff where the help_script file is located, inspect it to make sure it contains all the information you intended.

Example

Use cat help_script to see the content of the file.

login-1:~$ cat help_script 
Script started on 2024-12-17 22:20:08-05:00
login-1:~$ date
Tue Dec 17 22:20:11 EST 2024
login-1:~$ module load openmpi
Loading openmpi/gcc/11.3.0/zen2/4.1.5
  Loading requirement: gcc/11.3.0
login-1:~$ module list
Currently Loaded Modulefiles:
 1) hpcc/zaratan(default)   2) gcc/11.3.0   3) openmpi/gcc/11.3.0/zen2/4.1.5  
login-1:~$ ncap23
bash: ncap23: command not found
login-1:~$ exit
exit

Script done on 2024-12-17 22:21:08-05:00
login-1:~$

Please leave the script file in your directory and tell us the location. You do not need to attach it to the ticket.