20130320 logging with the script command - plembo/onemoretech GitHub Wiki

title: logging with the script command link: https://onemoretech.wordpress.com/2013/03/20/logging-with-the-script-command/ author: phil2nc description: post_id: 4511 created: 2013/03/20 09:56:13 created_gmt: 2013/03/20 13:56:13 comment_status: closed post_name: logging-with-the-script-command status: publish post_type: post

logging with the script command

When trying to debug a problem it sometimes helps to have a transcript of everything that happened on the console. Enter the Linux script command.

Script makes a typescript of everything printed on your terminal. It is useful for students who need a hardcopy record of an interactive session as proof of an assignment, as the typescript file can be printed out later with lpr(1).

It is also useful for old timers who are with increasing frequency called upon to do system archeology to discover exactly what a decades old program is really doing. Invoke like this:

script /tmp/test.log

The utility will then start a transcript of everything that happens next.

Script started on Wed 20 Mar 2013 09:52:51 AM EDT
^[]0;me@test:~/bin^G^[[?1034h[me@test bin]$ perl^H^[[K^H^[[K^H^[[Kp^H^[[Khp ldap_test.php^M
LDAP query test^M
Connecting using LDAPS...^M
ldap_create^M
ldap_url_parse_ext(ldaps://ldap.example.com)^M
connect result is Resource id #4^M
ldap_extended_operation_s^M
ldap_extended_operation^M
ldap_send_initial_request^M
ldap_new_connection 1 1 0^M
ldap_int_open_connection^M

Those "^M" characters are old-style Windows carriage returns. How user friendly! To end transcription do a "CNTRL-D" in the console.

Copyright 2004-2019 Phil Lembo