Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Okay, here's what I'm trying to do: I'd like to have a sort of "keylogger", if you will, to help me see exactly what happened for every command I have typed. (This will be used to troubleshoot/author tutorials, when possible.)
I'm thinking of something simple like:
Code:
$command | tee -a terminal.log | $stdout
However, I see a few problems with this. First, I want it to be completely transparent, so that it appears as if it is just running the command, and scrolling any/all output to the terminal. Also, I want to write the command itself, and then the output of it.
In theory, this would basically be a log of everything that appears on the terminal, except the "username@host:~$" parts. Although, it would be fine by me if it did include the "username@host:~" parts.
****Edit: I would like something that I can append to my "~/.bashrc" file, so that I will not have to directly invoke it each time I open a terminal window.****
Last edited by computer_freak_8; 02-01-2009 at 02:19 PM.
Reason: Add needed clarification.
I tried using script, but I can't quite seem to get it.
If I use this:
Code:
script -a /home/jaredtbrees/termlog.txt
Then I get this:
Code:
Script started, file is /home/jaredtbrees/termlog.txt
line after line after line, until I hit [Ctrl]+[C].
If I use this:
Code:
script -a -q /home/jaredtbrees/termlog.txt
Then I get only a blinking cursor - no "user@host:~$". Also, I cannot delete any text that I type, and the commands I type do not appear to do anything.
Either way, the file has no contents, even after issuing several commands.
Any suggestions?
The script ends when the forked shell exits (a control-D to exit the Bourne shell (sh(1)), and exit, logout or control-d (if ignoreeof is not set) for the C-shell, csh(1)).
@makyo:
Yes, I read over that exact same page, and figured that that was the problem.
@unSpawn:
When I started my terminal, I received this message above the "user@host:~$" prompt:
Quote:
bash: rootsh: command not found
So, I will try to install "rootsh" when I get a chance. (I tried "sudo apt-get install root[TAB]", and it is not listed, so apparently it is not in the Ubuntu repositories.)
it is as makyo said. control+c kill the current process. when you run the program, it writes everything to the file only when the program ands successfully. if you control+c, it won't write anthing to the fili. you must either use control+d to send and EOF signal, or type "exit".
it is as makyo said. control+c kill the current process. when you run the program, it writes everything to the file only when the program ands successfully. if you control+c, it won't write anthing to the fili. you must either use control+d to send and EOF signal, or type "exit".
But unless I kill the process, I am unable to use the terminal, making it useless in this context. Unless I missed something...
You may recall what I originally said about it:
Quote:
Originally Posted by computer_freak_8
If I use this:
Code:
script -a /home/jaredtbrees/termlog.txt
Then I get this:
Code:
Script started, file is /home/jaredtbrees/termlog.txt
line after line after line, until I hit [Ctrl]+[C].
What I meant by this is that it gives me the "Script started" line on my terminal, again, and again, and again, making my terminal unusable until I kill it. In addition, in my first post I mentioned:
Let us see if we can just get a transcript of a session into default collection file typescript.
Enter the command:
Code:
script
It looks like not much has happened, but now enter the following commands:
Code:
echo hi
wc
uname -a
echo hi | wc
exit
Do not enter control-c in the above sequence. That will stop the collecting. The last command
Code:
exit
that you entered will cause command script to halt.
What has happened is that command script begins watching your terminal. It captures the keystrokes you enter as well as results from the commands you have typed. It places all this data in default file typescript as well as appearing to normally place everything on the display.
So after the exit, you can cat, print, edit the file typescript as you wish.
If that's not what you want, then perhaps you can re-phrase your original question ... cheers, makyo
But unless I kill the process, I am unable to use the terminal, making it useless in this context. Unless I missed something...
You may recall what I originally said about it:
What I meant by this is that it gives me the "Script started" line on my terminal, again, and again, and again, making my terminal unusable until I kill it. In addition, in my first post I mentioned:
This would mean no "Script started" line at all.
strange. when i run script, i only get one "Script started" and the terminal continues as normal.
If that's not what you want, then perhaps you can re-phrase your original question ... cheers, makyo
What I'm looking for is a way to append something to my ~/.bashrc file, so that all sessions will be logged automatically. I now realize that I failed to specifically mention this, and although I did mention "~/.bashrc" in the title of the thread, I must not have been very clear. My apologies; no wonder why I wasn't getting what I was looking for! (I'm off to edit the original post.)
strange. when i run script, i only get one "Script started" and the terminal continues as normal.
Quote:
Originally Posted by norobro
I too, only get one "script started"
As I realized after reading the last post by user "makyo", my original post was unclear. I have edited the original post, and also clarified here. Sorry about that!
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.