Operating System - HP-UX
1753924 Members
8661 Online
108810 Solutions
New Discussion юеВ

Re: Capture shell stdout stderr in a file

 
SOLVED
Go to solution
Allanm
Super Advisor

Capture shell stdout stderr in a file

Hi!

I am currently installing a few packages and want to capture everything that I am typing and its output/err to a file to view later.

How can I achieve that in a bash shell? I am trying "exec command" but its not working for me.

Thanks,
Allan.
3 REPLIES 3
Dennis Handly
Acclaimed Contributor
Solution

Re: Capture shell stdout stderr in a file

If you want to just capture stdout/stderr, you can just redirect both files. In a real shell:
foo > foo.out 2>&1

If you want to capture what you type, see script(1).
Allanm
Super Advisor

Re: Capture shell stdout stderr in a file

Thanks Dennis script works.
muruganantham raju
Valued Contributor

Re: Capture shell stdout stderr in a file

Hi,

You can also achieve it like below.

#script
Script started, file is typescript



#exit
Script done, file is typescript

#cat typescript

You can get all the operations performed in the terminal in the file typescript

HTH
Muru