1753519 Members
4825 Online
108795 Solutions
New Discussion юеВ

Re: script output

 
SOLVED
Go to solution
Igor Sovin
Super Advisor

script output

Hi!
I have a script, that should make a file with it's output. How to do that?
Not using the following:
./myscript > output.file

Is it possible to add some command that would prescribe to save output of script in some file?
3 REPLIES 3
Ermin Borovac
Honored Contributor
Solution

Re: script output

You can add the following line at the start of myscript

exec > output.file 2>&1

this will redirect stdout and stderr to output.file.

You can also use command called script

$ script output.file
Script started, file is output.file
$ myscript
$ exit
Script done, file is output.file
renarios
Trusted Contributor

Re: script output

Hi Igor,

You can use the following:
1. ./script.sh 1>output.log 2>&1
2. nohup sh script.sh
3. nohup script.sh &
4. script output.log #spool output to output.log
./script.sh
exit #end spool

Does this help?

Cheerio,

Renarios
Nothing is more successfull as failure
Amit Agarwal_1
Trusted Contributor

Re: script output

would you like to use tee command.

./myscript | tee output.file

This would server your purpose but at the same time would display output on stdout too.