3 #=======================================================================
5 # File ID: af318500-fb9b-11dd-bb0f-000475e441b9
7 # Log the current terminal session with script(1)
9 # Author: Øyvind A. Holm <sunny@sunbase.org>
10 # License: GNU General Public License version 2 or later.
11 #=======================================================================
25 " -n "$progname" -- "$@
")"
26 test "$?" = "0" ||
exit 1
34 -h|
--help) opt_help
=1; shift ;;
35 -q|
--quiet) opt_quiet
=$
(($opt_quiet + 1)); shift ;;
36 -v|
--verbose) opt_verbose
=$
(($opt_verbose + 1)); shift ;;
37 --version) echo $progname $VERSION; exit 0 ;;
39 *) echo $progname: Internal error
>&2; exit 1 ;;
42 opt_verbose
=$
(($opt_verbose - $opt_quiet))
44 export LOGDIR
=$HOME/log
/script
/`date -u +"%Y/%m"`
46 if test "$opt_help" = "1"; then
47 test $opt_verbose -gt 0 && { echo; echo $progname $VERSION; }
50 Log the current terminal session with script(1) to
53 Usage: $progname [options] [SESSION_NAME]
60 Be more quiet. Can be repeated to increase silence.
62 Increase level of verbosity. Can be repeated.
64 Print version information.
71 test -z "$host" && host=$
([ -f ~
/.compname
] && cat ~
/.compname || hostname
)
73 [ -d $LOGDIR/.
] || mkdir
-p $LOGDIR ||
{ echo logging
: $LOGDIR: Cannot create log directory
>&2; exit 1; }
75 uuid
=`suuid -t logging -w eo -c "logging $host"` ||
{ echo logging
: Error when generating UUID
, logging not started
>&2; exit 1; }
76 export LNAME
="$LOGDIR/$LDATE.$uuid.$host"
77 SESS_UUID
="${SESS_UUID}logging/$uuid," script -ft $LNAME.scrlog
2>$LNAME.timing
78 suuid
-w e
-t logging
-c "Loggsession $uuid ferdig."
79 echo "Loggsession $uuid ferdig." >&2