Daniyaal Khan
Daniyaal Khan

Reputation: 285

Record Shell output

I wanted to know how to record all the input and output of my Ubuntu terminal.

Of course, I can use the script command but since I am using this in a shell script, it stops my script from going any further until I use the exit command and stop the recording.

Thanks in advance!

Upvotes: 2

Views: 261

Answers (1)

Andrey
Andrey

Reputation: 2583

You can use combination of script and interactive shell. The script:

#!/bin/sh
sh -i <<EOF
echo test
EOF

Capturing the input/output (works both in an interactive session and inside a script):

$ script -c ./script.sh 
Script started, file is typescript
sh$ echo test
test
sh$ exit
Script done, file is typescript

Result:

$ cat typescript 
Script started on 11 Apr 2014 10:23:13
sh$ echo test
test
sh$ exit

Script done on 11 Apr 2014 10:23:13

Upvotes: 2

Related Questions