Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Capture all input and output from a bash script

I am trying to capture all the input and output from a bash script that i created for installing nagios. I have it creating the log file using tee right now but it only shows when there is an echo command or some output from like "service httpd restart". I mainly want to capture the input the user is entering in the log file for future reference.

like image 617
Joe_Louis Avatar asked May 29 '26 23:05

Joe_Louis


1 Answers

The script command, run prior to your program, will capture all input and output to a file you specify. It terminates with a ctrl-D.

script -c yourprogram filename

may do what you're looking for. See the man page for script.

like image 194
bmb Avatar answered May 31 '26 14:05

bmb



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!