i wish to know how to use the script command inside a script.
when i try it exits the script.
i need to have alog file of a script that doesnt create log , so instead i want to have a file with all the output that was on the screen while the script runs.
I use exec > myscript.log, which will redirect stdout for remainder of script, or until overridden. That will replace any existing file of same name, or use >> to append to any existing file.
If your script then runs any child scripts, this directive will be in effect for them also. But a child script can issue its own exec command to direct all its output to its own log file. When the child script exits, the main script will still have its original exec directive in place.
While you have stdout redirected like this, you can still override this with output redirection on any given command. For example:
try creating another script containing the command to run the original script that you created. It would be something like this:
script -c ./original_script.sh
I did the same thing. my original script contains an expect script that telnets to a switch, throw some commands and then logout. I record everyting using the script command. so i created another script containing the line above to run the expect script while triggering the script command. Hope i was able to help