Saw one post here: Change PS1 after running the 'script' command but it didn't seem to answer the question.
I am trying to have a script run the "script" command and also change the prompt (PS1) to indicate that the shell is now scripted. Basically, the normal PS1 has "[UNSCRIPTED] in it in red so that the assessor knows they are not using a scripted window. Once they are ready to do their assessment, they would run this script, the window would now be scripted, and the prompt would change to indicate such.
Right now it works if you paste the commands one by one but when trying to role them into a script is does not work because the "script" command starts a new process so the PS1 change will only apply to the parent process (the shell script was ran from) and doesn't take effect until exiting the "script" process.
I have tried many variations of backgrounding the script process (&), running the commands in sequence (; and &&) but those all still wait for the parent process (the script command) to finish before moving on.
Here are the commands that work if ran line by line (copy/paste) but I cannot get to work in a shell script:
script -af /opdata/logs/scripted/script.$$
# SETUP WINDOW ENVIRONMENT
PS1='\d \t \u@\h \[\e[38;5;33m\]\w \[\e[0m\]# '
date -u
date
hostname
ifconfig -a
netstat -nr
uname -a