Script1 uses
echo
(and other commands) to standard output.Script1 also runs other scripts, which also use
echo
(and other commands) to standard output.Script1 is called by a scheduler that stores the standard output from Script 1 as report.
Is there a way for Script1 to copy its own standard output to a file?
(A possibility would be for another script, say Script0, to run Script1 with output directed to a file and printing that file, or use tee
to do both)
script1> outFile
script1
to always copy its output to a file (and not by specifying something on the command line), you would need to change each line to either use>
ortee
.>
will replace the contents in that output file. use>>
if you want to copy to the output file without replacing the content.sh
directly: replace the call to the script withsh -c '/path/to/script "$@" | tee log-file' _ arg1 arg2 ..