In the .profile of each user of the system (debian 8), I call a script who start a typescript session, to log everything in a file:
#!/bin/bash
script -f $HOME/.log/$(date +"%d-%b-%y_%H-%M-%S")_shell.log
The thing is when you enter "exit" then, you just stop the typscrit session, not the ssh connection, so you have to enter exit again. I would like to close ssh connection when we exit the typescript by enter "exit". I tried differents things:
At the end of my script:
exit
or
logout
or
$(logout)
All of this return an error after exiting the typescript, for instance with logout
or $(logout)
:
/pathtoscript/log.sh: 9: /pathtoscript/log.sh: logout: not found
But it's a system command so I just need to execute this in system at the end of the script and that should be good!
in .bashrc:
function exit() { builtin exit && exit; }
Nothing append with this function, when I hit "exit" the typescript stop but not the ssh session.