将BASH shell会话logging到主机上的文件的最佳方法是什么?
首选输出格式将等同于PuTTY的“可打印输出”日志设置,由用户查看,包括input和ncurses控制字符数据。
这可能是值得一看shell或系统审计程序,如rootsh或sudosh 。
您可以启动gnu屏幕并使用日志function。 我不知道什么会给你一个非常好的日志,像顶级的ncurses应用程序。
人屏幕
log [on|off] Start/stop writing output of the current window to a file "screenlog.n" in the window's default directory, where n is the number of the current window. This filename can be changed with the `logfile' command. ... logfile filename logfile flush secs Defines the name the log files will get. The default is "screenlog.%n". The second form changes the number of seconds screen will wait before flushing the logfile buffer to the file-system. The default value is 10 seconds.
TTYrec可能是最简单的解决scheme。 你可以使用原来的:
http://0xcc.net/ttyrec/index.html.en
或者滚动你自己的:
http://en.wikipedia.org/wiki/Ttyrec
或者,你可以得到所有的老学校和| 所有的命令都可以使用command.timestamp.tee
script程序将完整地logging你的shell会话。 不知道,如果它相当于任何腻子的东西。
你可以尝试使用http://xgu.ru/wiki/LiLaLo它是在俄罗斯,所以文件也是俄语,但谷歌翻译将帮助你。 这是一个输出的例子: alt text http://xgu.ru/w/images/1/1f/Lilalo-comment.png
我不确定你在这里想达到什么目的。 这是训练还是法医学? 如果你想要一些能产生良好的可读日志文件的东西,你可能不是很好。 如果你正在寻找能够播放会话,ttyrec就是你要的。 您可以将其作为login脚本的一部分来运行以捕获用户的会话,但要确保使用“陷阱”来阻止用户退出ttyrec并返回到shell。
所有input的命令都被写入.bash_history文件,通常在你家里。 您可以设置通过HISTFILESIZE设置存储的行数。
没有时间戳和输出,但是。
如果真的需要这样做,我会围绕bash做一个包装,将stdin和stdout复制到一个文件中,并通过它来处理。