1

Possible Duplicate:
DOS command to Display result on console and redirect the output to a file

tried various Google searches but nothing seemed to solve my problem.

Basically I'm working for a company who need me to work with their in place database and extract the various data need for reports. They are using Sqlite (please, I've heard enough comments about how it might not be the best choice for a DB, so leave them out) and I either want all my activity on Windows command prompt to be logged, or at least everything I do from the Sqlite command line to appear in a .txt, just in case I need to refer back to it later.

Can anybody here explain to me how to do this? I'm a bit of a beginner and need this stuff broken down step by step. Not done anything like this before.

Cheers!

Community
  • 1
  • 1
Chucky
  • 1,701
  • 7
  • 28
  • 62
  • 1
    This is *not* an exact duplicate. The cited question (and answers thereto) discuss only tee'ing the output. Here he clearly wants to log not only the *output* of what he does, but also the *input* he provides that causes those outputs. – Jerry Coffin Jun 23 '11 at 17:38
  • I voted to close as "off topic". The vote was 4 to 1 as "Exact duplicate". – John Saunders Jun 23 '11 at 20:06

1 Answers1

0

I'm reasonably certain you can't do this directly -- i.e., the Windows command prompt doesn't provide a way to log the input you provide to it. You can capture outputs (e.g., from commands you run), but for your purposes that's probably not adequate.

You probably need to create a "shell" of your own that takes inputs from the user, logs each one, sends it on to the command prompt, captures the output from the command prompt, and logs that as well.

In an answer to a previous question, I posted some code that handles most of what you need to do. The big difference is that you'll want to look in its handle_output (for example) and instead of just displaying the captured output to the console, write it to a file as well. As it stands right now, that example redirects the child's standard input to come from a file, but changing it to read from the console instead should be fairly straightforward -- you'll basically use a function about like the handle_output and handle_error that it already includes, but instead of displaying output, you'll read input from the user, and each line you'll 1) write to the log, and 2) send to the child via anonymous pipe (much like handle_output and handle_error read from anonymous pipes).

Community
  • 1
  • 1
Jerry Coffin
  • 476,176
  • 80
  • 629
  • 1,111
  • I don't have the rep to up your answer, but it looks like a good answer, although I'm unsure I'll be able to figure out how to implement what you described. I'm just not that good yet. At my University I'm sure there was a command to enter that allowed all command line activity for a MySql database to be logged, at least, on a Linux OS. I wish I knew how to do that. – Chucky Jul 04 '11 at 10:04